javaandroidgradleandroid-jetifier

Build failed with an exception. Reason: IllegalArgumentException, message: Unsupported class file major version 57


mxparser not working with jdk13

I am trying to use mxparser in my android project. I downloaded MathParser.org-mXparser-v.4.4.0-jdk13.jar and pasted it in libs folder of my project. But my app is failing to build and the build output is:

FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':app:mergeDebugJavaResource'. Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Failed to transform MathParser.org-mXparser-v.4.4.0-jdk13.jar to match attributes {artifactType=android-java-res, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for JetifyTransform: C:\Users\somagani\AndroidStudioProjects\MyApplication\app\libs\MathParser.org-mXparser-v.4.4.0-jdk13.jar. > Failed to transform 'C:\Users\somagani\AndroidStudioProjects\MyApplication\app\libs\MathParser.org-mXparser-v.4.4.0-jdk13.jar' using Jetifier. Reason: IllegalArgumentException, message: Unsupported class file major version 57. (Run with --stacktrace for more details.)

My dependencies in the build.gradle(:app) folder are

dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation files('libs\\MathParser.org-mXparser-v.4.4.0-jdk13.jar')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
       

And then I added the following to dependencies in my build:gradle project file

    classpath 'org.ow2.asm:asm:8.0'
    classpath 'org.ow2.asm:asm-util:8.0'
    classpath 'org.ow2.asm:asm-commons:8.0'

I got the following error due to that

FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':app:desugarDebugFileDependencies'. A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade Error while dexing.

Including the following line was of no use and gave the same error as above

classpath 'org.anarres.jarjar:jarjar-gradle:1.0.1'

Please help me out with this.


Solution

  • This is due to JDK version mismatch in the library. The library isn't updated to support the latest JDK version.

    I have tested that jdk10 version works perfectly

    MathParser.org-mXparser-v.4.4.0-bin-only.zip\MathParser.org-mXparser-v.4.4.0-bin-only\bin\jdk10
    
    implementation files('libs/MathParser.org-mXparser-v.4.4.0-jdk10.jar')
    

    I haven't tried other versions, you can give it a try.