Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Studio Ladybug - Unknown Kotlin JVM target: 21 #16

Open
Andrea2099 opened this issue Dec 2, 2024 · 3 comments
Open

Android Studio Ladybug - Unknown Kotlin JVM target: 21 #16

Andrea2099 opened this issue Dec 2, 2024 · 3 comments

Comments

@Andrea2099
Copy link

Andrea2099 commented Dec 2, 2024

Can't compile android, return this error Unknown Kotlin JVM target: 21

Add android and compile with LadyBug Android Studio

I fixed this issue in this way.

File:
[...]\node_modules@capacitor-community\image-to-text\android\build.gradle

BEFORE

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

AFTER

compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
      jvmTarget = "17" // Deve essere coerente con JavaVersion.VERSION_17
    }
@dtarnawsky
Copy link

You'll need to set your IDE to use Java 17. Android Studio > Settings > Build, Execution, Deployment > Build Tools > Gradle and choose a Grade JDK at version 17.

Capacitor 7 will support Java 21 but Capacitor 6 and plugins are designed to run with Java 17.

@Andrea2099
Copy link
Author

Yep

image

IDK in my case the build failed when the jvmTarget was not set in the kotlinOptions configuration, even though the Java version was set to 17.

    kotlinOptions {
      jvmTarget = "17" // Deve essere coerente con JavaVersion.VERSION_17
    }

@tiga05
Copy link

tiga05 commented Jan 4, 2025

I accidentally stumpled across this issue. I have the same problem since I use the image-to-text capacitor plugin. But it only appears if I try to build it via capacitor CLI on my windows pc and not when using Android Studio or on my build server.

My Android Studio settings:
image

My error in console with capacitor CLI:

capacitor.cmd run android --target Pixel_3a_API_34_extension_level_7_x86_64
[capacitor] √ Copying web assets from browser to android\app\src\main\assets\public in 808.98ms
[capacitor] √ Creating capacitor.config.json in android\app\src\main\assets in 1.08ms
[capacitor] [info] Inlining sourcemaps
[capacitor] √ copy android in 3.31s
[capacitor] √ Updating Android plugins in 21.11ms
[capacitor] [info] Found 13 Capacitor plugins for android:
[capacitor] @byteowls/[email protected]
[capacitor] @capacitor-community/[email protected]
[capacitor] @capacitor-community/[email protected]
[capacitor] @capacitor-community/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] @capacitor/[email protected]
[capacitor] √ update android in 242.87ms
[capacitor] × Running Gradle build - failed!
[capacitor] [error]
[capacitor] > Configure project :app
[capacitor] WARNING: Using flatDir should be avoided because it doesn't support any meta-data formats.
[capacitor]
[capacitor] > Configure project :capacitor-cordova-android-plugins
[capacitor] WARNING: Using flatDir should be avoided because it doesn't support any meta-data formats.
[capacitor]
[capacitor] FAILURE: Build failed with an exception.
[capacitor]
[capacitor] * What went wrong:
[capacitor] Could not determine the dependencies of task ':capacitor-community-image-to-text:compileDebugKotlin'.
[capacitor] > Unknown Kotlin JVM target: 21
[capacitor]
[capacitor] * Try:
[capacitor] > Run with --stacktrace option to get the stack trace.
[capacitor] > Run with --info or --debug option to get more log output.
[capacitor] > Run with --scan to get full insights.
[capacitor] > Get more help at https://help.gradle.org.
[capacitor]
[capacitor] BUILD FAILED in 2s
[capacitor]
[ERROR] An error occurred while running subprocess capacitor.
`

So @Andrea2099 you are not alone with this error and your temporary fix worked for me, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants