I had a gradle problem with my M1 few months ago when I update Android Studio code. I stumbled a week trying all the suggestions. Finally got it work. to compile. I taking a flutter Udemy course. so learning that and manage a new dev environment.
I migrated my M1 Macbook pro to a M4 Macbook pro few days ago. I updated Android Studio by mistake at that time. So now my VS IDE is failing on gradle build on my new M4 mac. When I try to compile a simple Flutter app compiles fine on M1.
I check my M1
My android studio whos grade JDK jbr-17. 17.0.12 distributionUrl=https://services.gradle.org/distributions/gradle-8.3-all.zip
My Mac M4 i have tried to setup same versions. but still getting error on compile for gradle.
This error:
Launching lib/main.dart on sdk gphone64 arm64 in debug mode…
Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ‘:path_provider_android:compileDebugJavaWithJavac’.
Could not resolve all files for configuration ‘:path_provider_android: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: /Users/bsanderson/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar.
> Error while executing process /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/jlink with arguments {–module-path /Users/bsanderson/.gradle/caches/transforms-3/d9e926982c2c139ff9125eb7b6be4144/transformed/output/temp/jmod –add-modules java.base –output /Users/bsanderson/.gradle/caches/transforms-3/d9e926982c2c139ff9125eb7b6be4144/transformed/output/jdkImage –disable-plugin system-modules}
- Try:
Run with –stacktrace option to get the stack trace.
Run with –info or –debug option to get more log output.
Run with –scan to get full insights.
Get more help at https://help.gradle.org.
BUILD FAILED in 18s
Error: Gradle task assembleDebug failed with exit code 1
Exited (1).
I have tried flutter clean to clear cache.
Questions
I check the gradle site for the table that shows compatable java and gradle versions. I have tried setting to match but my M4 still errors on gradle build.
Short of wiping out my Dev environment and rebuild it. not a big issue since I do have everything on github. But really want to learn why this is happening to self fix in future.
thanks
bill sanderson
2
Answers
I spent the last two days trying to downgreade Android Studio JDK listed in FLutter Doctor as jdk ver 21. I ended up. Deleting Android Studio 100% env. Reinstall. I have jdk 17 selected in Android gradle wrapper. I have sdk jdk 17 selected for all environments on my mac.
I was able to finally compile past gradle errors today for first time.
My issue was Flutter Doctor --verbose was showing Androids jdk versions as:
Application finished. bsanderson@Bill-M4-Macbook meals2 % flutter doctor --verbose [✓] Flutter (Channel stable, 3.24.5, on macOS 15.1 24B2082 darwin-arm64, locale en-US) • Flutter version 3.24.5 on channel stable at /Users/bsanderson/Development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision dec2ee5c1f (6 days ago), 2024-11-13 11:13:06 -0800 • Engine revision a18df97ca5 • Dart version 3.5.4 • DevTools version 2.37.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/bsanderson/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11) • All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 16.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16B40 ✗ Unable to get list of installed Simulator runtimes. • CocoaPods version 1.15.2
[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
Which was throwing my into a tial spin try to get version jdk 17 to be used since flutter says it not support jdk 21 yet.
I am able to compile test code in flutter android app using VS Code IDE now. yet flutter doctor --verbose is showing jdk 21 for Android config.
do not know why this is the case.
hope this help someone else...
Update com.android.application plugin to version 8.3.2 in projectroot/android/settings.gradle file.
If you can’t find this file you can create one at root of Android folder of Flutter project and copy paste below content: