Nurin Afiza
Nurin Afiza

Reputation: 21

Execution failed for task ':app:mergeExtDexDebug'. Could not resolve all files for configuration ':app:debugRuntimeClasspath'

i want to run my flutter project but got this error:

FAILURE: Build failed with an exception.

 * What went wrong:
 Execution failed for task ':app:mergeExtDexDebug'.
 > 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=23, 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 DexingWithClasspathTransform: C:\Users\User\.gradle\caches\transforms-3\a497fff099218d09578e12c23e9f46a7\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=23, 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 DexingWithClasspathTransform: C:\Users\User.gradle\caches\transforms-3\039b4c1f544ca04a871af3153003f63c\transformed\appcompat-1.7.0-runtime.jar. > Error while dexing.

* 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.

this is my android/app/build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
    id "com.google.gms.google-services" // Add this line
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file("local.properties")
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader("UTF-8") { reader ->
    localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
    flutterVersionCode = "1"
}

def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
    flutterVersionName = "1.0"
}

android {
    namespace = "com.example.my_tflite_app"
    compileSdk = flutter.compileSdkVersion
    ndkVersion '21.1.6528147'

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID   (https://developer.android.com/studio/build/application-id.html).
       applicationId = "com.example.my_tflite_app"
       // You can update the following values to match your application needs.
       // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdk = 23 // Updated minSdkVersion to 23
        targetSdk = flutter.targetSdkVersion
        versionCode = flutterVersionCode.toInteger()
        versionName = flutterVersionName
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig = signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}

dependencies {

    implementation 'androidx.core:core-ktx:1.13.1'
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'com.google.android.material:material:1.12.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

// Add these lines for Firebase
implementation platform('com.google.firebase:firebase-bom:31.2.0') 
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth' // Add Firebase Auth dependency
}

Upvotes: 2

Views: 7071

Answers (3)

Waseem Abbas
Waseem Abbas

Reputation: 865

In a Flutter project, we don't need to add the following dependencies:

implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation platform('com.google.firebase:firebase-bom:31.2.0') 
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth'

These dependencies from the build.gradle should be removed if you are not natively creating views in Android. Even to integrate the firebase in a flutter project we don't need to add the dependencies for Android/iOS separately. Read here to learn how to integrate firebase in flutter apps.

Upvotes: 0

tycorporationgroup
tycorporationgroup

Reputation: 41

I have solved it,downgrade the verison of androidx.appcompact to 1.6.1 as 1.7.0

Upvotes: 4

Nipul Rathod
Nipul Rathod

Reputation: 822

Try this:

Change compileSdkVersion in android/app/build.gradle:

android {
    namespace "App Name"
    compileSdk 34 //Change here
    ndkVersion flutter.ndkVersion
}

And also change minSdkVersion and targetSdkVersion:

defaultConfig {
        minSdkVersion 24 
        targetSdkVersion 34
        versionCode = flutterVersionCode.toInteger()
        versionName = flutterVersionName
    }

Also you can add multidex manually if this isn't work:

dependencies {
  implementation 'com.android.support:multidex:2.0.1' //enter the latest multidex version
}
android {
    defaultConfig {
        multiDexEnabled true
    }
}

Upvotes: 0

Related Questions