Android: Dex cannot parse version 52 byte code
just use java 1.8 with Android Studio 3.0+ and set following works for me:
it seems need the latest build tools
classpath 'com.android.tools.build:gradle:3.0.0'
and
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
...
//jackOptions { // DEPRECATED
//enabled true
//}
}
dexOptions {
incremental true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Error:Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code
Thanks everyone for answer. The problem was that this library (compile 'com.myhexaville:smart-image-picker:1.0.4'
) gave conflict. When I removed it everything worked finally.
Building Cordovo Android app fails - Dex cannot parse version 52 byte code error message
It reads:
ParseException: bad class file magic (cafebabe) or version (0034.0000)
0x0034
is version 52 byte code, which means the some class had been compiled with JDK 8, which is not being understood by that version of dex
. It even explicitly demands the source/target compatibility mode:
Dex: 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.
So there are two options:
a) either follow the advice and edit the compileOptions
(this not only applies to the java
plugin):
android {
compileOptions {
// sourceCompatibility JavaVersion.VERSION_1_6
// targetCompatibility JavaVersion.VERSION_1_6
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
b) build with JDK 8.
You are actually building with rather old versions:
dependencies {
classpath "com.android.tools.build:gradle:2.2.3"
}
task wrapper(type: Wrapper) {
gradleVersion = "2.14.1"
}
while the current versions are:
dependencies {
classpath "com.android.tools.build:gradle:3.5.0"
}
task wrapper(type: Wrapper) {
gradleVersion = "5.4.1"
}
When I read version 2.2.3
I'd assume a version of Android Studio just as old. Update to Android Studio 3.5.0
and have an embedded JRE 8 installed with it. That Android Studio might still have an embedded JRE 7 (no matter what the JDK on path claims to be, because the global JDK and the embedded JRE are two different installations). The same goes for Gradle, because it might use the local wrapper at version 2.14.1
instead of the global installation at version 5.6.1
. One can tell Gradle to use a specific JDK with org.gradle.java.home
, but the IDE might in general be too old. You'd need at least Android Studio 3.0.0 for Java 8 support.
cordova error: Dex: Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code
Version 52 byte code corresponds to Java 8, you need to add below to your app/build.gradle
to make your project be compatible with Java 8.
android {
...
defaultConfig {
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
}
Android Error converting bytecode to dex: Cause: Dex cannot parse version 52 byte code
YOu change
compileOptions.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
to
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Related Topics
Using File.Listfiles with Filenameextensionfilter
Getting Strange Output When Printing Result of a String Comparison
"Java Dateformat Is Not Threadsafe" What Does This Leads To
Javafx - Border Radius <-> Background Color
How to Get an Android User's Email Address
How to Select and Crop an Image in Android
Change Icons of Checked and Unchecked for Checkbox for Android
Dynamically Get Drawables by Id
Why Doesn't Java Throw an Exception When Dividing by 0.0
How to Implement in Java ( Jtextfield Class ) to Allow Entering Only Digits
How to Use Jsp/Jstl to Generate Dynamic CSS/JavaScript Files
How to Fix Google Cloud Messaging Registration Error: Service_Not_Available
Android - Preventing Webview Reload on Rotate
Decompile an APK, Modify It and Then Recompile It
Passing a JavaScript Object Using Addjavascriptinterface() on Android