Dx不支持的类文件版本52.0 ...在解析com/example/test1/BuildConfig.class时

ana*_*mar 7 eclipse android java-8 eclipse-neon

尝试使用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
Run Code Online (Sandbox Code Playgroud)

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

lar*_*fer 21

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

如果你想在你的资源中使用lambdas,你可以使用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类文件.

  • 这使我指出了正确的方向.在eclipse中试用Android我不得不将编译器版本和jre版本降级到1.7然后我不再遇到这个问题.更多信息:我从来没有看到任何记录任何错误很长一段时间,并总是想知道为什么Android模拟器没有向我展示我的hello world项目.只有当我更改构建设置以生成.apk(取消选中"跳过包装和dexing直到导出或启动")时,我才开始获取Android的这些控制台日志.也许这有助于某人. (2认同)