-
Notifications
You must be signed in to change notification settings - Fork 526
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
Build Failure due to JVM Target Compatibility Issue in flutter_unity_widget (Kotlin 17 vs Java 1.8) #986
Comments
Which Unity version did you use, and which jvm settings are in your gradle files? |
Thank you for your quick reply!
However, I couldn't find any code specifying the JVM version in the other
|
I am also getting the same issue |
Me too, I am also getting this issue. |
I am also getting the same issue |
Hi, I found a temporary solution while waiting for this library to be updated to a higher version of Java. The library currently uses Java version 1.8. However, since my project uses Java 17, I need to modify the Java version in this library. Here are the steps:
Hope this helps! |
1.download this dependency https://github.com/juicycleff/flutter-unity-view-widget |
I am also getting the same issue |
me too, I am also getting the same issue |
I did exactly that, used the local dependency from master branch and updated the Am I missing something? |
@WouterVandenputte 3. in the above downloaded dependency change android/build.gradle of above you changed this inside the downloaded dependency or in the project . make sure you open local downloaded dependency first and inside it change android/build.gradle this |
I changed all build.gradle in unityLibrary, android/app, and downloaded dependency to 17. However, the same error occurs. Unity (please complete the following information):
Smartphone (please complete the following information):
Additional context
|
Can anyone try if this (temporary) workaround works? Update this in your local project files. //<flutter project>/android/build.gradle
// make sure this is above any use of "evaluationDependsOn"
subprojects {
afterEvaluate {
if (project.plugins.hasPlugin("com.android.application")
|| project.plugins.hasPlugin("com.android.library")) {
if (project.name == "flutter_unity_widget") {
// override version numbers if needed
project.android.compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
project.android.kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}
project.android {
// add namespace if it is missing
if (namespace == null) {
namespace = project.group
}
// you can also override stuff like compileSdk
// compileSdk = 34
}
}
}
}
}
// this should already be in your android/build.gradle file.
subprojects {
project.evaluationDependsOn(":app")
} This error is likely due to a requirement change in some new gradle/AGP versions, for which the plugin is now outdated. I just got this error after making the following gradle changes. (Flutter 3.24.5) // settings.gradle
- id "com.android.application" version "7.4.2" apply false
+ id "com.android.application" version "8.1.0" apply false
- id "org.jetbrains.kotlin.android" version "1.8.21" apply false
+ id "org.jetbrains.kotlin.android" version "1.8.22" apply false
//gradle-wrapper.properties
- distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip |
This works for me. compileSdk = 34 was required. And it could also be solved with the method below. gradle.properties
|
Describe the bug
When trying to run a Flutter application with the flutter_unity_widget package using "Run and Debug" in VS Code, an error occurs during the build process. The error specifically states a mismatch between the Java version for the compileDebugJavaWithJavac (targeting 1.8) and the compileDebugKotlin (targeting 17). The build fails as a result.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The Flutter application should successfully run on the connected Android device without any build errors.
Error details
Unity (please complete the following information):
Smartphone (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: