6

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?

Community
  • 1
  • 1
rossman
  • 63
  • 1
  • 5
  • You'll need to attach your build files to the question to get a better answer. It's not clear what this classes.jar is that got generated during the build, and why it's including that class. – Scott Barta Apr 23 '14 at 16:45
  • The GameCricleSDK library is part of the [Amazon Mobile App SDK](https://developer.amazon.com/public/resources/development-tools/sdk), it is not my code. Apparently nobody is trying to use this library in Android Studio... – rossman Apr 30 '14 at 04:42
  • I'm an Amazon developer in the games division working on Android. I don't work on the GameCircle team, but I'm going to pass along this issue to them. – SomeCallMeTim Jun 12 '14 at 07:21
  • Thanks for passing this along @SomeCallMeTim! – rossman Jun 26 '14 at 06:27

2 Answers2

17

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

mar3kk
  • 1,886
  • 2
  • 17
  • 21
  • Sorry for the long delay in responding, but can you please provide more detail? Which manifest did you change? – rossman Jun 06 '14 at 06:20
  • I edited my answer, I hope it's understandable now ;) – mar3kk Jun 09 '14 at 11:41
  • Thanks, I looked through AndroidManifest.xml files in my library modules, and found the same package name which I wrongly used for a new module – Mixaz Oct 23 '14 at 14:49
  • @mar3kk after changing the package name, it is ok in debug build but I suffer java.lang.NoClassDefFoundError on the release build – LoGary Dec 18 '14 at 08:37
  • Hmm first I would check if proguard is enabled and if it is I would disable it or change rules to keep the class which is missing – mar3kk Dec 18 '14 at 17:36
  • 1
    Changing the package name in the manifest prevent the class inside the library project to use the `res`present in the library project. This is not a solution whera library project is used because it's not possible to add `res` in a jar – Hugo Gresse Apr 08 '15 at 09:52
  • This was not the cause of the issue in my case, rather I had gamecirclesdk.jar both in my Library project's lib folder and my main project's lib folder. Please check for multiple gamecirclesdk.jar in your project. – shaby Feb 28 '17 at 07:01
0

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.

Chris.Zou
  • 4,506
  • 6
  • 31
  • 38
  • AFAiK You cannot set applicationId in library module anymore using recent android gradle plugin. – mar3kk Apr 09 '15 at 19:39