7

尝试使用 JDK 1.8 和 eclipse neon 构建项目时出现以下错误:

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:

[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/BuildConfig.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/MainActivity.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$attr.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$dimen.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$id.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$layout.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$menu.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$mipmap.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$string.class

[2016-07-03 02:40:59 - Test1] Dx 
PARSE ERROR:
[2016-07-03 02:40:59 - Test1] Dx unsupported class file version 52.0
...while parsing com/example/test1/R$style.class

[2016-07-03 02:40:59 - Test1] Dx 11 errors; aborting
[2016-07-03 02:40:59 - Test1] Conversion to Dalvik format failed with error 1

我需要更改哪些项目设置来修复它们?

4

1 回答 1

21

您必须告诉您的 java 编译器生成与 java 7 兼容的类文件,因为 android (dex) 目前不支持 java 8。

如果您想在源代码中使用 lambda,可以使用 retrolambda ( https://github.com/evant/gradle-retrolambda ) 或新的 Jack 编译器 ( https://developer.android.com/preview/j8-jack .html )

更新: 从 Android Studio 3.0 和 Android Gradle Plugin 3.0 开始,也可以使用 java 8 类文件。

于 2016-07-02T21:43:44.657 回答