You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The majority of issues come from using the latest Android Studio (Ladybug 2024.2.1), which ships the Java SDK 21.
e.g. running flutter doctor -v:
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
• Android SDK at /home/miquel/Android/Sdk
• Platform android-35, build-tools 35.0.0
• ANDROID_HOME = /home/miquel/Android/Sdk
• Java binary at:
/home/miquel/.local/share/JetBrains/Toolbox/apps/android-studio/jbr/bin/ja
va
• Java version OpenJDK Runtime Environment (build 21.0.3+-12282718-b509.11)
• All Android licenses accepted.
The simplest solution is to downgrade Android Studio and use Java 17, now, let's attempt to fix this with the latest Android Studio version.
Compilation issues
The first compilation issue you will see with a newly created project with Flutter 3.24.3 and adding connectivity_plus (or any other Android plugin) is:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':connectivity_plus:compileReleaseJavaWithJavac'.
> Could not resolve all files for configuration ':connectivity_plus:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: /home/miquel/Android/Sdk/platforms/android-34/core-for-system-modules.jar.
> Error while executing process /home/miquel/.local/share/JetBrains/Toolbox/apps/android-studio/jbr/bin/jlink with arguments {--module-path /home/miquel/.gradle/caches/transforms-3/4a46fc89ed5f9adfe3afebf74eb8bfeb/transformed/output/temp/jmod --add-modules java.base --output /home/miquel/.gradle/caches/transforms-3/4a46fc89ed5f9adfe3afebf74eb8bfeb/transformed/output/jdkImage --disable-plugin system-modules}
Checking project dependencies
The project comes with the following AGP:
id "com.android.application" version "8.1.0" apply false
id "com.android.application" version "8.3.1" apply false
All these follow the minimum version requirements as specified by the plugin README file.
Now the project compiles again:
Running Gradle task 'assembleRelease'... 13.4s
✓ Built build/app/outputs/flutter-apk/app-release.apk (18.7MB)
NDK Error
You may see the following error on screen:
Your project is configured with Android NDK 23.1.7779620, but the following plugin(s) depend on a different Android NDK version:
- connectivity_plus requires Android NDK 25.1.8937393
Fix this issue by using the highest Android NDK version (they are backward compatible).
Add the following to /home/miquel/tmp/connectivity_error_2/android/app/build.gradle:
android {
ndkVersion = "25.1.8937393"
...
}
Seems that you can ignore this error, as the project still compiles.
Changing the Java SDK
You can try to set the Jdk path using the flutter config --jdk-dir command. I haven't tried that but it's something you can consider if everything else fails.
Download and install the JDK 17.
Use flutter config --jdk-dir to configure it.
Check the version again with flutter doctor -v
The text was updated successfully, but these errors were encountered:
This ticket contains some tips to help mitigate recent Android compilation issues.
Before attempting any solution, ensure that your project has been migrated to the new Android project structure:
You can also find a reference to the different Android Gradle Plugin (AGP) and Gradle versions here:
There is also a main ticket on flutter/flutter discussing this issue:
source value 8 is obsolete
/target value 8 is obsolete
flutter/flutter#156111What causes the issue
The majority of issues come from using the latest Android Studio (Ladybug 2024.2.1), which ships the Java SDK 21.
e.g. running
flutter doctor -v
:The simplest solution is to downgrade Android Studio and use Java 17, now, let's attempt to fix this with the latest Android Studio version.
Compilation issues
The first compilation issue you will see with a newly created project with Flutter
3.24.3
and addingconnectivity_plus
(or any other Android plugin) is:Checking project dependencies
The project comes with the following AGP:
And the following gradle wrapper:
Checking plugin requirements
The plugins README lists the following version requirements:
Upgrading dependencies
To apply these, change the following:
Open
android/app/build.gradle
and change:Open
android/gradle/wrapper/gradle-wrapper.properties
and change:Open
android/settings.gradle
and change:All these follow the minimum version requirements as specified by the plugin README file.
Now the project compiles again:
NDK Error
You may see the following error on screen:
Seems that you can ignore this error, as the project still compiles.
Changing the Java SDK
You can try to set the Jdk path using the
flutter config --jdk-dir
command. I haven't tried that but it's something you can consider if everything else fails.flutter config --jdk-dir
to configure it.flutter doctor -v
The text was updated successfully, but these errors were encountered: