skip to Main Content

When i run my flutter project for my phone, i get this error (which i hadn’t before updating android studio & other things like flutter & dependencies) :

Launching lib/main.dart on moto e40 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sqflite_android:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':sqflite_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: /home/user/Documents/programmation/Android/sdk/platforms/android-34/core-for-system-modules.jar.
         > Error while executing process /home/user/Downloads/rpms/archives/android-studio.new/jbr/bin/jlink with arguments {--module-path /home/user/.gradle/caches/transforms-3/4a46fc89ed5f9adfe3afebf74eb8bfeb/transformed/output/temp/jmod --add-modules java.base --output /home/user/.gradle/caches/transforms-3/4a46fc89ed5f9adfe3afebf74eb8bfeb/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 5s
Error: Gradle task assembleDebug failed with exit code 1

i tried several things, including :

  • deleting ~/.graddle/caches
  • deleting ~/.graddle
  • deleting ~/.pub-cache
  • switching back to the old android studio version
  • pub remove / add sqflite

2

Answers


  1. Chosen as BEST ANSWER

    Solved it by updating id "com.android.application" version "8.1.0" apply false to id "com.android.application" version "8.7.2" apply false in android/settings.graddle

    android studio didn't told me there was a newer version

    (got that info here)


  2. This has worked for me when I have tried to update my project from android 33 or lower to android 34 for my earlier flutter project

    flutter clean

    flutter pub get

    flutter pub upgrade –major-versions (if project show too many outdated dependencies)

    update android/app/build.gradle as below please find android 34 mig in below file changes

    android {
    
        // android 34 mig => added
        namespace = "packagename" 
        compileSdkVersion 34
    
        // android 34 mig => removed
    /*
        sourceSets {
            main.java.srcDirs += 'src/main/kotlin'
        }
    
        lintOptions {
            disable 'InvalidPackage'
        }
    */
    
        // android 34 mig => added
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_1_8
            targetCompatibility = JavaVersion.VERSION_1_8
        }
        kotlinOptions {
            jvmTarget = "1.8"
        }
    
        defaultConfig {
            applicationId "package"

    update android/setting.gradle as below please find android 34 mig in below file changes

    // android 34 mig => updated all file
    
    pluginManagement {
        def flutterSdkPath = {
            def properties = new Properties()
            file("local.properties").withInputStream { properties.load(it) }
            def flutterSdkPath = properties.getProperty("flutter.sdk")
            assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
            return flutterSdkPath
        }()
    
        includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
    
        repositories {
            google()
            mavenCentral()
            gradlePluginPortal()
        }
    }
    
    plugins {
        id "dev.flutter.flutter-plugin-loader" version "1.0.0"
        id "com.android.application" version "7.3.1" apply false
    //    id "org.jetbrains.kotlin.android" version "1.9.23" apply false
        id "org.jetbrains.kotlin.android" version "2.0.21" apply false
    }
    
    include ":app"

    update android/gradle/wrapper/gradle-wrapper.properties as below please find android 34 mig in below file changes

    // android 34 mig => updated or new version
    distributionUrl=https://services.gradle.org/distributions/gradle-8.4-bin.zip

    Update android/build.gradle android 34 mig and find

    buildscript {
    // android 34 mig => updated or new version
        ext.kotlin_version = '1.7.20'

    And then try below commands

    flutter clean

    flutter pub get

    flutter run

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search