flutterflutter-upgradeflutter-update

After running flutter upgrade my projects are not building on IOS and Android and gives error:ERROR:/Users/username/.gradle/caches/


I Upgraded the flutter to the lates version today at 24th of September 2024 and my project that i was working on is not compiling and building any more and give this error of android devices when i what to install the app for test:

*ERROR:/Users/UserName/.gradle/caches/transforms-3/525a3ec9924944fdf720d87028d1e961/transformed/appcompat-1.7.0-runtime.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "" is null ERROR:/Users/UserName/.gradle/caches/transforms-3/23f325e1b838060e9e8064e2aaad3f0e/transformed/jetified-appcompat-resources-1.7.0-runtime.jar: D8: java.lang.NullPointerException: Cannot invoke "String.length()" because "" is null

FAILURE: Build failed with an exception.

Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Failed to transform appcompat-resources-1.7.0.aar (androidx.appcompat:appcompat-resources:1.7.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for DexingNoClasspathTransform: /Users/harry/.gradle/caches/transforms-3/23f325e1b838060e9e8064e2aaad3f0e/transformed/jetified-appcompat-resources-1.7.0-runtime.jar. > Error while dexing. Failed to transform appcompat-1.7.0.aar (androidx.appcompat:appcompat:1.7.0) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=24, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for DexingNoClasspathTransform: /Users/harry/.gradle/caches/transforms-3/525a3ec9924944fdf720d87028d1e961/transformed/appcompat-1.7.0-runtime.jar. > Error while dexing.

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.


Solution

  • I find the solution:

    1. make sure you have the latest version of the flutter flutter upgrade
    2. Run this flutter pub upgrade --major-versions -> this will get the most updated and compatibility versions of the packages in Android and IOS and flutter
    3. then just run flutter clean && flutter pub get

    Up to here this will solve the problem for the IOS

    NOW FOR ANDROID:

    1. get to android/gradle/wrapper/gradle-wrapper.properties and change the distributionUrl version to: distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip

    2. then get to android/settings.gradle and update these 2 lines id "com.android.application" version "8.5.0" apply false and id "org.jetbrains.kotlin.android" version "2.0.20" apply false

    3. now get to android/app/build.gradle and update these 2 lines compileSdk = 34 and ndkVersion = "26.1.10909125" All DONE Hope this solution helped you