adwiv / android-fat-aar

Gradle script that allows you to merge and embed dependencies in generted aar file
The Unlicense
1.46k stars 435 forks source link

com.android.dex.DexException: Multiple dex files define Lcom/android/submodule/BuildConfig; #51

Closed mklueh closed 4 years ago

mklueh commented 7 years ago

I´m using fat-aar to merge six modules, which are forming my library I´m exporting. In addition, I have an application module in my project to test the library.

Error:Execution failed for task ':TestApp:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/android/submodule/BuildConfig;

I was using an older fat-aar version before (0.1) I think, together with gradle 1.2.3 and build-tools 23.0.3, which worked perfectly. But with the current version of both my test application is unusable.

Has anyone experienced similar issues?

monkeydone commented 7 years ago

I have same issue.

mklueh commented 7 years ago

I have now managed to get the BuildConfig error away by removing cycling module inclusions temporarily and modifying fat-aar a bit to exclude BuildConfigs, but now I´m getting the same error with my own classes of my submodule. The simplified hierarchy consists now just of one application, the library module and one submodule.

task embedJavaJars(dependsOn: "embedRClass") << {
    println "Running FAT-AAR Task :embedJavaJars"

    embeddedAarDirs.each { aarPath ->
        // Explode all classes.jar files to classes so that they can be proguarded
        copy {
            from zipTree("$aarPath/jars/classes.jar")
            exclude '**/BuildConfig.class' //This line was added to exclude BuildConfigs
            into classs_release_dir
        }

        // Copy all additional jar files to bundle lib
        FileTree jars = fileTree(dir: "$aarPath/jars", include: '*.jar', exclude: 'classes.jar')
        jars += fileTree(dir: "$aarPath/jars/libs", include: '*.jar')
        jars += fileTree(dir: "$aarPath/libs", include: '*.jar')

        copy {
            from jars
            into file("$bundle_release_dir/libs")
        }

        // Copy all embedded jar files to bundle lib
        copy {
            from embeddedJars
            into file("$bundle_release_dir/libs")
        }
    }
}
talobin commented 7 years ago

I have the same issue and the work-around for me right now is to enable multidex in the build.gradle of whichever module it is complaining.