Error during the build on Android Studio with @capacitor/barcode-scanner

Hello,

I don’t arrive to build/run the application on Android Studio because of the barcode-scanner package (version 1.0.2 or 1.0.4… not tried on 2.0.x).
Here is the error message I get:

Execution failed for task ':capacitor-barcode-scanner:compileDebugKotlin'.
> Inconsistent JVM-target compatibility detected for tasks 'compileDebugJavaWithJavac' (17) and 'compileDebugKotlin' (21).

1. What is it?
2. Can I solve it without upgrading to Capacitor V7 for the moment?

Thanks for your help,
Loïc

To confirm, you set minSdkVersion = 26 (reference)?

What version of Android Studio and what OS (Windows, Linux, Mac) are you running?

In Android Studio, if you go to File → Settings → Build, Execution, Deployment → Build Tools → Gradle, what is the Gradle JDK set to?

Hi @twestrick,

Thanks for your reply :slight_smile:

Yes, minSdkVersion = 26. (and the other settings defined in the documentation are the same too)

I use Android Studio Ladybug Feature Drop | 2024.2.2 on MacOs.

Here are the Gradle JDK settings:
image

Is there something wrong?

I would try JDK v17. I had similar problems when I upgraded to Ladybug in my Capacitor 6 app since Ladybug now defaults to v21.

To downgrade, you have to download v17 via that interface. Make sure it is in a different location than v21. It didn’t work for me in the same location.

Also, after changing the version I had to restart my computer to have it take affect as the Gradle Daemon was caching v21.

1 Like

Hi Tom,

Many thanks for your help, it works fine after downgrading to v17 :slight_smile:

Have a nice day,
Loïc

1 Like