16

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.

Oscar Salguero
  • 10,275
  • 5
  • 49
  • 48

3 Answers3

11

This should be fixed in in 2.0.0-alpha6, now available. https://sites.google.com/a/android.com/tools/tech-docs/new-build-system

Tor Norbye
  • 9,062
  • 3
  • 29
  • 24
  • Woah! That was fast! Thank you! – Oscar Salguero Jan 16 '16 at 06:31
  • The fix seems to work and after a cleaning and rebuilding the project using 2.0.0-alpha6, Android Studio is pushing the APK to a Nexus 5X with Marshmallow, a Nexus 5 with KitKat, a simulator with Jelly Bean and Samsung Galaxy S with Gingerbread as 2.0.0-alpha3. To make it work on the Nexus 5X, I had to clear the cache of the app, uninstall it and restart the device (if I just tried to replace the old APK by hitting run, it wouldn't work and would show lots of errors about bootstrap classes inside the APK). Thanks again! – Oscar Salguero Jan 16 '16 at 06:50
  • 2
    alpha6 fixed that one issue but I had another when I tried to run the app. So disabling Instant Run was the only solution for me :-( – bkurzius Jan 19 '16 at 17:12
  • I'm using the NDK, preview6, alpha6 plugin and got INSTALL_FAILED_INVALID_APK: /data/app/vmdl1312093572.tmp/1_main version code 2005 inconsistent with 8002005. Please help! – WindRider Jan 21 '16 at 21:09
  • 1
    I am on alpha8. Still see this – Chad Bingham Jan 29 '16 at 01:44
  • @ChadBingham same here. – alashow Jan 29 '16 at 03:41
5

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!

bkurzius
  • 4,020
  • 2
  • 34
  • 34
0

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)

Christlin Panneer
  • 1,599
  • 2
  • 19
  • 31