Multiple dex files define Lcom/amazon/ags/BuildCon

2020-07-11 08:03发布

问题:

I recently imported my Android project from Eclipse into AndroidStudio. Everything went fairly well, and I was able to resolve most issues, except when it came down to the GameCircleSDK library module. I kept getting the following error:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/amazon/ags/BuildConfig;

As it turns out, the com.amazon.ags.BuildConfig.class was indeed contained in two jars: classes.jar (which got generated during the build) and GameCircleSDK/libs/gamecirclesdk.jar.

The only way I could solve the issue was to unzip the gamecirclesdk.jar, remove the BuildConfig.class, and zip it back up again. I searched the internets for a solution, and I tried just about everything listed here, but nothing seemed to resolve my situation. Am I missing something?

回答1:

The problem is that GameCricleSDK.jar contains BuildConfig file with package name "com.amazon.ags" and the whole module is also generating BuildConfig file with the same package name as declared in Manifest. I changed the package name in module Manifest file and problem went away.

SOLUTION: Take the GameCircleSDK library, open it's AndroidManifest.xml and change the packageName from "com.amazon.ags" to sth else no matter what. I changed it to "com.amazon.ags.lib".



回答2:

I ran into the same problem using a different library project though(WeiboSDK). You may also need to change the applicationId in the library's build.gradle file to the same value in the library's AndroidManifest.xml.