我用java 7 android studio错误替换java 8?

all*_*218 4 android android-studio

为什么我用JAVA 7替换JAVA 8,安卓工作室错误?

> 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.
Error:...while parsing android/support/v7/recyclerview/R$attr.class
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.
Error:...while parsing android/support/v7/recyclerview/R$dimen.class
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.
Error:...while parsing android/support/v7/recyclerview/R$id.class
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.
Error:...while parsing android/support/v7/recyclerview/R$styleable.class 
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.
Error:...while parsing android/support/v7/recyclerview/R.class
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.
Error:...while parsing com/example/administrator/comjarlib/R$anim.class
Error:Error converting bytecode to dex:
............
Run Code Online (Sandbox Code Playgroud)

我想在Android Studio中使用retroLambda.

任何面临类似问题/已解决的人都可以给出一些指针来解决它.

我正在使用2.10级的Android Studio 2.1预览版3

Vic*_*ens 13

这个帮助了我.在项目的主build.gradle文件中,将这些代码行添加到allprojects部分中(如果不存在,则添加此部分).

allprojects {

    tasks.withType(JavaCompile) {
        sourceCompatibility = 1.7
        targetCompatibility = 1.7
    }

}
Run Code Online (Sandbox Code Playgroud)


Nic*_*ard 5

如果我没有错误gradle android插件扩展'java'插件,所以你可以在build.gradle的"android"块中添加这两行:

apply plugin: 'com.android.application'

android {

    targetCompatibility = '1.7'
    sourceCompatibility = '1.7'

    ...
}
Run Code Online (Sandbox Code Playgroud)

为我工作得很好.