0

I already read this article and all other related: Android: Dex cannot parse version 52 byte code

But still I have next issue while doing build:

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'

When I do: gradlew installDebug - it installs application to device. But when I start application from Run/Debug - it fails with this error. I am using Java SDK 1.8 and JAVA_HOME path is defined to C:\Program Files\Java\jdk1.8.0_151.

Does any one know how to fix this? Thanks.

yozhik
  • 4,644
  • 14
  • 65
  • 98

2 Answers2

1

Go to Build... Clean Project then run the project again This worked for me

0

There's some IDE related .idea files that must be changed also, using the IDE the following changes it to 1.8:

Go to File... Project Structure...

Select the app module and in the main tab (properties) select Target Compatibility to 1.8

Marcos Vasconcelos
  • 18,136
  • 30
  • 106
  • 167