Split lib_main was defined multiple times

AndroidAndroid StudioAndroid Studio-2.0

Android Problem Overview


Split lib_main was defined multiple times

In "com.android.tools.build:gradle:2.0.0-alpha3" build success, But the errors that occur in the "com.android.tools.build:gradle:2.0.0-alpha5".

console error


finally instant run work!! com.android.tools.build:gradle:2.0.0-alpha8 and gradle.properties "org.gradle.jvmargs = -Xmx8g" was resolved to change.

Android Solutions


Solution 1 - Android

Just delete build folder of appmodule and Rebuild the project!

This will fix the issue!.

Solution 2 - Android

For those who wonder what InstantRun is (first setting in the picture): enter image description here

And yes disabling that setting fixes the issue.

Edit 01/19/16

'com.android.tools.build:gradle:2.0.0-alpha6' was released three days ago. Using that new version, the "Split lib_main was defined multiple times" error is gone and installation of the app succeeds but now I get a runtime error:

java.lang.RuntimeException: Unable to instantiate application
com.android.tools.fd.runtime.BootstrapApplication:
java.lang.ClassNotFoundException: Didn't find class
"com.android.tools.fd.runtime.BootstrapApplication" on path:
DexPathList[[zip file "/data/app/com.onegravity.k10.pro2-2/base.apk",
zip file "/data/app/com.onegravity.k10.pro2-/split_lib_main.apk"]
    
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.android.tools.fd.runtime.BootstrapApplication" on path:
DexPathList[[zip file "/data/app/com.onegravity.k10.pro2-2/base.apk",
zip file "/data/app/com.onegravity.k10.pro2-2/split_lib_main.apk"]
    
Suppressed: java.io.IOException: No original dex files found for dex location
/data/app/com.onegravity.k10.pro2-2/base.apk
    
Suppressed: java.lang.ClassNotFoundException:
com.android.tools.fd.runtime.BootstrapApplication

Turning off instant run eliminates that error. Let's wait for com.android.tools.build:gradle:2.0.0-alpha7...

Edit 01/25/16

'com.android.tools.build:gradle:2.0.0-alpha7' was released two days ago.

Getting the same exception as with 2.0.0-alpha6

Solution 3 - Android

I ran into this issue after refactoring and changing app name in gradle. Following AskQ's lead, I rebuilt the project (following a slightly different path):

Build-> Clean Project

followed by

Build-> Rebuild Project

Solved the issue

Solution 4 - Android

Recovery:

Deleting the (projectFolder)/app/build folder and re-building worked for me. (as answered by @AskQ)

I wonder if Build > Clean Project would have worked as well; from the Android Studio GUI menus.

Avoidance:

In my case the problem seems to have occurred because I had copy pasted a project, so 2 projects had the same name.
There are like other causes too, learning what they are can help users avoid this concern.

Solution 5 - Android

It might happen because of your package name is in uppercase, so you must change it back to lowercase.

Solution 6 - Android

Android studio 2.3.3 It worked for me after disabling Instant run in settings...

Go to Settings-> Build,Execution and Development-> Instant Run -> Uncheck Enable Instant Run to hotswap then clean project and Rebuild your project again!!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionshinhyoView Question on Stackoverflow
Solution 1 - AndroidAskQView Answer on Stackoverflow
Solution 2 - AndroidEmanuel MoecklinView Answer on Stackoverflow
Solution 3 - Androidtony gilView Answer on Stackoverflow
Solution 4 - AndroidBrian DavisView Answer on Stackoverflow
Solution 5 - AndroidRaja Nurfarahin FarhanahView Answer on Stackoverflow
Solution 6 - AndroidSuhasView Answer on Stackoverflow