16
votes

Android Studio is not pushing my APK into a physical Nexus 5X with Marshmallow (6.0.1).

This is the output and the error:

01/15 01:51:48: Launching mobile
$ adb install-multiple -r /Users/MyUser/AndroidStudioProjects/MyApp/mobile/build/outputs/apk/mobile-development-debug-unaligned.apk /Users/MyUser/AndroidStudioProjects/MyApp/mobile/build/intermediates/split-apk/development/debug/main.apk /Users/MyUser/AndroidStudioProjects/MyApp/mobile/build/intermediates/split-apk/development/debug/main.apk 

Error installing split apks: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_INVALID_APK: Split lib_main was defined multiple times
Error during launch

Details:

defaultConfig: minSdkVersion 9 targetSdkVersion 23 multiDexEnabled true

2 buildTypes: debug and release

2 productFlavors: development and production

dexOptions: incremental false preDexLibraries = false jumboMode = true javaMaxHeapSize "4096M"

I'm using the latest Android Studio 2.0 Preview 5 (http://tools.android.com/recent/androidstudio20preview5available).

Gradle: distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip

And the build tools are: 'com.android.tools.build:gradle:2.0.0-alpha5'.

Is there a way to tell Android Studio no to use install-multiple to install the apk?

UPDATE (01/15/2016 2:26 AM EST):

The issue doesn't happen when running the app on a Galaxy Nexus emulator with Jelly Bean (4.3.1) nor a physical Samsung Galaxy S with Gingerbread (2.3.6).

UPDATE (01/15/2016 11:30 AM EST):

Ran the app on a Nexus 5 with KitKat (4.4.4) and it works just fine.

3
Are you using the NDK? - Andres Perez
No @andresperezl, not using NDK. The curious thing is that the issue doesn't happen with a Galaxy Nexus emulator with Jelly Bean nor a physical Samsung Galaxy S with Gingerbread. - Oscar Salguero
On which device and Android version you are running this app? - Geeky Singh
@RacZo disable instant run. - Alexei Korshun

3 Answers

11
votes
5
votes

There seem to be multiple issues with the new Gradle Plugins - both with alpha5 and alpha6. But it looks like if all else fails you need to disable Instant Run. For me this particular error was resolved by using alpha6 as @Tor Norbye indicated above -- but then I had this error instead https://code.google.com/p/android/issues/detail?id=195044

Instant Run will be a pretty cool feature when they work out the kinks!

0
votes

I just faced similar issue in Android Studio 3.3; while i'm duplicating the project into another project by changing the package and application id information.

Since the old application is installed on the target device the following 2 options are working

1. Clean the project and Build it again (Working)

2. Uninstall the previous app on the device (Working)