I’m using @capacitor/barcode-scanner in a reactjs project. The web version runs perfectly, but an error occurs for the mobile app ver.
I got this error when running the application
Execution failed for task ‘:capacitor-barcode-scanner:compileDebugKotlin’.
Inconsistent JVM-target compatibility detected for tasks ‘compileDebugJavaWithJavac’ (17) and ‘compileDebugKotlin’ (21).
I tried to change the java version in capacitor.build.gradle file but it will revert back to original when sync.
I also install jdk 17 and jdk 21 to try which one is suitable, but still received the same error.
Here are the solutions I’ve tried:
Link 1
Link 2
Link 3
Does the error come from Capacitor Barcode Scanner plugin or the Android?
2
Answers
If you are using latest JDK to your project then you can make changes in build.gradle(app-level) and your project will run successfully.
and
If jdk 21 version not works.
Then java 17 is always safer option to choose.
in gradle change source and target compatibility to 17 version for better stability