Java 错误:将字节码转换为dex Android Studio 3.0时出错

Java 错误:将字节码转换为dex Android Studio 3.0时出错,java,android,android-studio,Java,Android,Android Studio,我已经阅读了这篇文章和所有其他相关文章: 但在进行构建时,我还有一个问题: Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code. This is caused by library dependencies that have been compiled using Java 8 or above. If you are using the 'java' gradle plugi

我已经阅读了这篇文章和所有其他相关文章:

但在进行构建时,我还有一个问题:

Error:Error converting bytecode to dex:
Cause: Dex cannot parse version 52 byte code.
This is caused by library dependencies that have been compiled using Java 8 or above.
If you are using the 'java' gradle plugin in a library submodule add 
targetCompatibility = '1.7'
sourceCompatibility = '1.7'
to that submodule's build.gradle file.
Android Studio 3.0.1

classpath 'com.android.tools.build:gradle:2.3.3'
buildToolsVersion '26.0.2'
compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
compileSdkVersion 26
    buildToolsVersion '26.0.2'
当我这样做时:gradlew installDebug-它将应用程序安装到设备上。 但当我从Run/Debug启动应用程序时,它会失败并出现此错误。 我使用的是Java SDK 1.8,Java_主路径定义为C:\Program Files\Java\jdk1.8.0_151


有人知道如何解决这个问题吗?谢谢。

有些与IDE相关的.idea文件也必须更改,使用IDE,以下将其更改为1.8:

转到文件。。。项目结构


选择应用程序模块,然后在主选项卡(属性)中选择目标兼容性到1.8

转到构建。。。清理项目,然后再次运行该项目 这对我有用