-
Notifications
You must be signed in to change notification settings - Fork 532
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
[Unity 6] Unknown Kotlin JVM target: 21 #992
Comments
I am facing the same issue. Any workaround? |
Have not found any workarounds so I had to revert to the 2022.3.53f1 version of Unity and am just using the main branch of this plugin for now. Hoping to update to Unity 6 again when this issue is resolved. |
@SuTechs @TergelEnkhtur I'm on Unity 2023.2.19f1 and got the same error and was able to fix it by:
$ brew install openjdk@17
$ flutter config --jdk-dir /opt/homebrew/opt/openjdk@17
$ flutter doctor
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Applications/Unity/Hub/Editor/2023.2.19f1/PlaybackEngines/AndroidPlayer/SDK
• Platform android-35, build-tools 34.0.0
• Java binary at: /opt/homebrew/opt/openjdk@17/bin/java
• Java version OpenJDK Runtime Environment Homebrew (build 17.0.13+0)
• All Android licenses accepted.
android {
ndkVersion "23.1.7779620"
ndkPath "/Applications/Unity/Hub/Editor/2023.2.19f1/PlaybackEngines/AndroidPlayer/NDK"
// ...
} |
Thank you for your detailed response @devidw! I will definitely try this fix when I have the time! |
Worked for me thank @devidw |
Describe the bug
This error is bizarre as it runs fine when i run it in the android folder by clicking the run button in Android Studio, but does not run when I try to do the same in the root of the flutter project. The thing is, I am trying to publish this app to the Android and App stores and am worried that it will not pass the checks there or will fail to run in the users' phones if I ignore this error.
I followed this to have a working build for this plugin that uses Unity 6 as that is important for my project but sadly it did not work for me:
#967
Also this one:
https://stackoverflow.com/questions/79090643/android-studio-ladybug-unknown-kotlin-jvm-target-21
Could not determine the dependencies of task ':flutter_unity_widget:compileDebugKotlin'.
This is the main error that pops up and I tried a lot of different things but could not fix it. Please help.
Steps I took
I got the build.cs file from the experimental/unity_6000 branch and replaced my own Assets/FlutterUnityIntegration/Editor/Build.cs file with it.
I made sure to bump the Kotlin version to Java 17 in app/build.gradle:
Details
compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = JavaVersion.VERSION_17 } kotlin { jvmToolchain(17) // I also tried this, did not work } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "mn.argun.arconte" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = 23 targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode versionName = flutter.versionName }
I have also went to Android Studio -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle. Under Gradle Projects -> Gradle JDK. I changed it from GRADLE_LOCAL_JAVA_HOME: JetBrains Runtime 21.0.3 - aarch64 to homebrew-17: Homebrew OpenJDK 17.0.13.
This fixes the same Unknown Kotlin JVM target: 21 error when it first appears when I click the run button in the android folder, but does not it the root folder.
Also, File -> Project Structure looks like this in the root folder:
The SDK used to be: No SDK, but I tried changing that to homebrew-17.
gradle-wrapper.properties:
distributionUrl=https://services.gradle.org/distributions/gradle-8.4-bin.zip
I have also tried the recommended 8.9 version update, still the same.
android/settings.gradle:
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version '8.3.0' apply false
id "org.jetbrains.kotlin.android" version "1.9.10" apply false
}
To Reproduce
Steps to reproduce the behavior:
0. Use the example project or create new project
The 3 logs below seem to be the same error, but just in case they are different, I will list them.
This is the error log when I click the run button in the root of the project:
Details
This is the log when i do 'flutter run' in the terminal in the root folder:
Details
This is the log when i do 'flutter run' in the terminal by writing 'cd' to the android folder while still being in the root folder opened in Android Studio:
Details
This is when i do 'flutter run' with Android Studio open to the '/android' folder:
Details
Expected behavior
I expect it to run without problems on my android phone.
Screenshots
I am sure you know this, but this is the run button in Android Studio I am talking about.
This is the sync output in the android folder:
This is the run/build output:
This the Android Gradle Plugin version I am using and it is recommending me to update to 8.7.2 which I tried, does not make a difference:
Unity (please complete the following information):
Smartphone (please complete the following information):
Flutter doctor
Details
The text was updated successfully, but these errors were encountered: