Dx unsupported class file version 52.0 ...while parsing com/example/test1/BuildConfig.class

anand kumar picture anand kumar · Jul 2, 2016 · Viewed 16.5k times · Source

I'm getting the following errors when attempting to build a project using JDK 1.8 and 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

Which project settings do I need to change to fix them?

Answer

larsgrefer picture larsgrefer · Jul 2, 2016

You have to tell your java compiler to produce java 7 compatible class files, because android (dex) does not support java 8 at the moment.

If you want to use lambdas in your sources, you can use retrolambda (https://github.com/evant/gradle-retrolambda) or the new Jack compiler (https://developer.android.com/preview/j8-jack.html)

Update: Since Android Studio 3.0 and Android Gradle Plugin 3.0, java 8 classfiles can be used, too.