Cannot create android app from an archive containing both DEX and Java-bytecode content

132 Views Asked by At

Thanks in advance for helping here, as I've been stuck in the mud for a couple of days now with the following error below:

> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
   > Cannot create android app from an archive containing both DEX and Java-bytecode content.
aused by: com.android.tools.r8.internal.Ub: Cannot create android app from an archive containing both DEX and Java-bytecode content.
    at com.android.tools.r8.ArchiveProgramResourceProvider.getProgramResources(R8_8.1.68_081071c36a35dea9a8e7845c23af618c2d62fb486760a022308124c1698d2e82:24)
    at com.android.builder.dexing.R8ProgramResourceProvider.addProgramResourceProvider(r8Tool.kt:470)
    at com.android.builder.dexing.R8Tool.runR8(r8Tool.kt:237)

I'm not sure if it's about a java library that is messing things up. AGP version : 8.1.4 Gradle Version : 8.3

These are the files:

build.gradle.kts


plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("dagger.hilt.android.plugin")


}

android {
    namespace = "com.example.fittestapp"
    compileSdk = 34

    defaultConfig {
        applicationId = "com.example.fittestapp"
        minSdk = 34
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary = true
        }
        multiDexEnabled = true

    }

    buildTypes {

        debug {
            isMinifyEnabled = true
            isShrinkResources = true
            multiDexEnabled = true
        }
        release {
            isShrinkResources = true
            isMinifyEnabled = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
            multiDexEnabled = true
        }
    }




    configurations {
        all { // You should exclude one of them not both of them
            // exclude (group= "org.jetbrains.kotlin", module= "kotlin-compiler-embeddable")
            exclude(group = "net.sf.kxml", module = "kxml2")
            exclude(group = "org.jetbrains.kotlin", module = "kotlin-build-statistics")
            exclude(group = "org.jetbrains.kotlin", module = "kotlin-build-tools-api")
            exclude(group = "org.jetbrains.kotlin", module = "kotlin-gradle-plugin")
            exclude(group = "xmlpull", module = "xmlpull")
            exclude(group = "xmlpull", module = "xpp3")
            exclude(group = "xpp3", module = "xpp3")
            exclude(group = "com.google.dagger", module = "hilt-android-compiler")
            exclude(group = "com.google.dagger", module = "hilt-compiler")
            exclude(group = "com.android.tools.build", module = "builder")
            exclude(group = "jakarta.activation", module = "jakarta.activation-api")

        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs = listOf(
            "-Xstring-concat=inline"
        )
    }
    buildFeatures {
        compose = true
    }
    composeOptions {
        kotlinCompilerExtensionVersion = "1.5.6"

    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1,DEPENDENCIES,public-suffix-list.txt}"
            excludes += "/**/*.txt"
            excludes += "kotlin/coroutines/coroutines.kotlin_builtins"
            excludes += "xsd/catalog.xml"
            excludes += "META-INF/mimetypes.default"
            excludes += "kotlin/kotlin.kotlin_builtins"
            excludes += "kotlin/reflect/reflect.kotlin_builtins"
            excludes += "kotlin/collections/collections.kotlin_builtins"
            excludes += "META-INF/mailcap.default"
            excludes += "META-INF/LICENSE.md"
            excludes += "META-INF/NOTICE.md"
            excludes += "META-INF/io.netty.versions.properties"
            excludes += "kotlin/annotation/annotation.kotlin_builtins"
            excludes += "META-INF/INDEX.LIST"
            excludes += "kotlin/internal/internal.kotlin_builtins"
            excludes += "kotlin/ranges/ranges.kotlin_builtins"
            excludes += "META-INF/gradle/incremental.annotation.processors"

        }
    }
}

dependencies {
    implementation("androidx.core:core-ktx:1.12.0")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
    implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
    implementation(platform("androidx.compose:compose-bom:2023.10.00"))
    implementation("androidx.compose.ui:ui")
    implementation("androidx.compose.ui:ui-graphics")
    implementation("androidx.compose.ui:ui-tooling-preview")
    implementation("androidx.compose.material3:material3")
    implementation("androidx.compose.material3:material3-window-size-class:1.1.2")

    implementation("androidx.room:room-common:2.6.0")
    implementation("javax.inject:javax.inject:1")
    implementation("androidx.compose.runtime:runtime-livedata:1.6.0-beta01")
    implementation("androidx.navigation:navigation-runtime-ktx:2.7.5")

    implementation("androidx.constraintlayout:constraintlayout-compose:1.1.0-alpha13")
    implementation("com.github.bumptech.glide:glide:5.0.0-rc01")
    implementation("androidx.work:work-testing:2.9.0-rc01")
    implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0-rc01")

    implementation("androidx.work:work-runtime:2.8.1")
    implementation("androidx.hilt:hilt-work:1.1.0")
    implementation("com.google.dagger:hilt-android:2.49")
    implementation("com.google.dagger:hilt-android-testing:2.49")
    implementation("com.google.dagger.hilt.android:com.google.dagger.hilt.android.gradle.plugin:2.49")
    implementation("androidx.compose.ui:ui-viewbinding:1.5.4")
    implementation("androidx.activity:activity-compose:1.8.1")
    implementation("androidx.navigation:navigation-compose:2.7.5")
    implementation("androidx.hilt:hilt-navigation-compose:1.1.0")
    implementation("androidx.navigation:navigation-safe-args-gradle-plugin:2.7.5")
    implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0-Beta1")
    implementation(platform("org.jetbrains.kotlin:kotlin-bom:2.0.0-Beta1"))
    implementation("org.jetbrains.kotlin:kotlin-build-tools-api:2.0.0-Beta1")
    implementation("org.jetbrains.kotlin:kotlin-native-utils:2.0.0-Beta1")
    implementation("androidx.constraintlayout:constraintlayout:2.2.0-alpha13")
    implementation("androidx.compose.ui:ui-android:1.6.0-beta02")
    implementation("androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03")
    implementation("com.google.dagger:hilt-compiler:2.49")
    implementation("com.google.dagger:hilt-android-compiler:2.49")
    implementation("com.google.android.gms:play-services-auth-blockstore:16.2.0")
    implementation("com.google.android.gms:play-services-location:21.0.1")
    implementation("androidx.multidex:multidex:2.0.1")
    implementation("com.android.tools.build:gradle:8.3.0-alpha17")
    implementation("com.github.bumptech.glide:compose:1.0.0-beta01")

    androidTestImplementation("androidx.test.ext:junit:1.1.5")

    androidTestImplementation(platform("androidx.compose:compose-bom:2023.10.00"))
    androidTestImplementation("androidx.compose.ui:ui-test-junit4")
    debugImplementation("androidx.compose.ui:ui-tooling")
    debugImplementation("androidx.compose.ui:ui-test-manifest")
    androidTestImplementation("androidx.test.ext:junit:1.1.5")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
}

build.gradle.kts (module)

plugins {
    id("com.android.application") version "8.1.4" apply false
    id("org.jetbrains.kotlin.android") version "1.9.21" apply false
    id("androidx.navigation.safeargs.kotlin") version "2.7.5" apply false
    id("com.google.dagger.hilt.android") version "2.49" apply false
}

I'm unsure if I should share anything else, but please let me know.

1

There are 1 best solutions below

0
On

I've filed b/317330821 in the D8/R8 issue tracker. The issue you have is some dependency that includes both DEX and Java bytecode and the compiler does not know how to handle that as only one of them is likely supposed to be included as part of the program.

The compiler should provide information about which input is causing this, but from your error message it appears to not be the case. Filed b/317330821 to address that.