Reputation: 1
I'm experiencing an issue with my Flutter project when trying to build it using Gradle. The build fails with the following error:
> Task :app:mergeExtDexDebug FAILED
ERROR: /home/abadidi/.gradle/caches/8.8/transforms/56c9a3fbcd208cf82b6416faec55188a/transformed/jetified-desugar_jdk_libs-2.0.4/classes.dex: D8: Attempt at compiling intermediate artifact without its context
ERROR: D8: com.android.tools.r8.internal.Ge: Merging DEX file containing classes with prefix 'j$.' with other classes, except classes with prefix 'java.', is not allowed: _COROUTINE.ArtificialStackFrames, _COROUTINE.CoroutineDebuggingKt, _COROUTINE._BOUNDARY, _COROUTINE._CREATION, android.annotation.SuppressLint, android.annotation.TargetApi, android.support.customtabs.ICustomTabsCallback$Default, android.support.customtabs.ICustomTabsCallback$Stub$Proxy, android.support.customtabs.ICustomTabsCallback$Stub, android.support.customtabs.ICustomTabsCallback$_Parcel, android.support.customtabs.ICustomTabsCallback, android.support.customtabs.ICustomTabsService$Default...
What went wrong:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Here is my app/build.gradle
file:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'dev.flutter.flutter-gradle-plugin'
id 'com.google.gms.google-services' apply false
}
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.example"
compileSdk = 34
ndkVersion = "26.1.10909125"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
coreLibraryDesugaringEnabled true
}
kotlinOptions {
jvmTarget = "11"
}
packagingOptions {
exclude("META-INF/DEPENDENCIES")
exclude("META-INF/INDEX.LIST")
exclude("META-INF/LICENSE")
exclude("META-INF/LICENSE.txt")
exclude("META-INF/license.txt")
exclude("META-INF/NOTICE")
exclude("META-INF/NOTICE.txt")
exclude("META-INF/notice.txt")
}
defaultConfig {
applicationId = "com.example.example"
minSdk = 26
multiDexEnabled true
targetSdk = 34
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64', 'x86'
}
}
buildTypes {
release {
signingConfig = signingConfigs.debug
minifyEnabled true
}
}
}
flutter {
source = "../.."
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:33.0.0')
implementation 'com.google.firebase:firebase-analytics'
implementation("com.google.firebase:firebase-appcheck")
implementation("com.google.firebase:firebase-auth")
implementation("com.google.firebase:firebase-firestore")
implementation 'com.google.auth:google-auth-library-oauth2-http:1.23.0'
implementation 'com.google.firebase:firebase-messaging:24.0.0'
implementation 'com.android.tools:desugar_jdk_libs:2.0.4'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
implementation 'com.android.support:multidex:2.0.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.window:window:1.0.0"
}
Here is my project-level build.gradle
file:
buildscript {
ext.kotlin_version = '1.9.24'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.4.1'
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.1'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
Here is my gradle.properties
file:
org.gradle.jvmargs=-Xmx4608m
org.gradle.parallel=true
org.gradle.caching=true
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.vfs.watch=true
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
I've tried updating all dependencies and ensuring that multiDexEnabled
is set to true
, but the issue persists. Any guidance on how to resolve this would be greatly appreciated.
defaultConfig {
multiDexEnabled true
}
I also changed compileOptions
and kotlinOptions
to java 17, the issue persists
Upvotes: 0
Views: 217