douarbou
douarbou

Reputation: 2283

UNEXPECTED TOP-LEVEL EXCEPTION: On Android Studio and not Eclipse

I have an issue when I try to build my project, here my structure : ActionBarSherlock (Project lib) -->(linked) A Project (Lib) -->(linked) to Project Test

When I try to run the project test on eclipse every things are fine but when I changed for Android Studio I have that issue:

Android Dex: [sample] UNEXPECTED TOP-LEVEL EXCEPTION:
Android Dex: [sample] java.lang.IllegalArgumentException: already added: Lcom/myClassPath/MyClassName;
Android Dex: [sample] at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
Android Dex: [sample] at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
Android Dex: [sample] at com.android.dx.command.dexer.Main.processClass(Main.java:490)

Someone can help me, please Thanks

Upvotes: 4

Views: 3999

Answers (3)

saiyancoder
saiyancoder

Reputation: 1325

A Build -> Clean Project and a full new Build did the trick for me.

Upvotes: 1

Software.Developer
Software.Developer

Reputation: 999

I encountered this problem. My fix was different however...

Android Dex: [sample] java.lang.IllegalArgumentException: already added: Lcom/myClassPath/MyClassName;

It turns out that MyClassName was in 2 different modules. In both locations, the class had the same package name.

To fix it, I just removed the one that was in the incorrect location. To find out where it is you can CTRL + SHIFT + F for "class MyClassName", that should show you all instances of where that class is defined.

Upvotes: 0

Ahmad
Ahmad

Reputation: 72583

You have to check the modules of both projects. Make sure they are both using the same version of the support library (or any other lib they are both using).

Upvotes: 6

Related Questions