admin管理员组

文章数量:1122832

Edited

I still don't know the solution to this but I change from using @capacitor/barcode-scanner to html5-qrcode npm package. It still gives off the same functionalities but I don't have to deal with the error anymore.

But if you know the solution to my issue, feel free to share.


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?

Edited

I still don't know the solution to this but I change from using @capacitor/barcode-scanner to html5-qrcode npm package. It still gives off the same functionalities but I don't have to deal with the error anymore.

But if you know the solution to my issue, feel free to share.


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?

Share Improve this question edited Dec 3, 2024 at 8:01 nur najihah asked Nov 22, 2024 at 1:46 nur najihahnur najihah 816 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

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

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.

compileOptions {
    sourceCompatibility JavaVersion.VERSION_21 // Adjust the version to the one that works for your project.
    targetCompatibility JavaVersion.VERSION_21 // Adjust the version to the one that works for your project.
}

and

kotlinOptions {
    jvmTarget = '21'  // Adjust the version to the one that works for your project.
}

本文标签: