Search code examples
androidfluttergradle

Flutter build fails after updating dependencies


My project worked fine until I've tried to install a new package, and all of the sudden my previously working packages isn't working, here is an error from "google_sign_in" package:

FAILURE: Build failed with an exception.  
What went wrong: Execution failed for task ':google_sign_in_android:compileDebugJavaWithJavac'.
Could not resolve all files for configuration ':google_sign_in_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/pezhvak/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar. > Error while executing process /Users/pezhvak/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/jlink with arguments {--module-path /Users/pezhvak/.gradle/caches/8.8/transforms/4c4ec335038410e4c484aa095ddf9d65-c534e869-7e4e-4da9-a418-dec3e27819d0/transformed/output/temp/jmod --add-modules java.base --output /Users/pezhvak/.gradle/caches/8.8/transforms/4c4ec335038410e4c484aa095ddf9d65-c534e869-7e4e-4da9-a418-dec3e27819d0/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 2s Error: Gradle task assembleDebug failed with exit code 1

I've tried:

  • clearing gradle cache
  • installing the new api (Android 15 Api Level 35)
  • removing and reinstalling packages
  • downgrading the package version

Neither worked, i even tried to install google_sign_in in a fresh new project and the problem is still there, the same issue is happening with url_launcher package.

Note: this is not happening with IOS, it works fine with it.


Solution

  • So it turned out to be the issue with the new android studio LadyBug.

    After macros release 15.0.1 (Sequoia) I've updated everything with it but it didn't show up the issue until i tried to install a new package (i guess because of gradle caches).

    How to fix:

    Open android/settings.gradle and change this line:

    id "com.android.application" version "8.7.0" apply false
    

    Then open android/gradle/wrapper/gradle-wrapper.properties and change this:

    distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
    

    This should fix the issue, however there will be errors in the logs, to fix them do this:

    open android/app/build.gradle and make sure ndkVersion is set to 27.0.12077973:

    ndkVersion = "27.0.12077973"
    

    There might be better ways to do this, and it will be probably fixed soon by flutter, but until then this will hopefully help you continue developing your app.

    Sources: