java 安装拆分 apk 时出错:com.android.ddmlib.InstallException:无法完成会话:INSTALL_FAILED_INVALID_APK

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34805780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 23:23:31  来源:igfitidea点击:

Error installing split apks: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_INVALID_APK

javaandroidandroid-studioandroid-gradle-plugin

提问by Oscar Salguero

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

Android Studio 没有将我的 APK 推送到带有 Marshmallow (6.0.1) 的物理 Nexus 5X。

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

defaultConfig: minSdkVersion 9 targetSdkVersion 23 multiDexEnabled true

2 buildTypes: debug and release

2 buildTypes:调试和发布

2 productFlavors: development and production

2 产品风味:开发生产

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

dexOptions: 增量 false preDexLibraries = false jumboMode = true javaMaxHeapSize "4096M"

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

我正在使用最新的 Android Studio 2.0 Preview 5 ( http://tools.android.com/recent/androidstudio20preview5available)。

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

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

构建工具是:'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?

有没有办法告诉 Android Studio 不使用 install-multiple 来安装 apk?

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

更新(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).

在带有 Jelly Bean (4.3.1) 的 Galaxy Nexus 模拟器或带有 Gingerbread (2.3.6) 的物理三星 Galaxy S 上运行该应用程序时,不会发生该问题。

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

更新(01/15/2016 东部时间上午 11:30):

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

在带有 KitKat (4.4.4) 的 Nexus 5 上运行该应用程序,它运行良好。

回答by Tor Norbye

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

这应该在 2.0.0-alpha6 中修复,现在可用。https://sites.google.com/a/android.com/tools/tech-docs/new-build-system

回答by bkurzius

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

新的 Gradle 插件似乎存在多个问题 - alpha5 和 alpha6。但看起来如果所有其他方法都失败了,您需要禁用 Instant Run。对我来说,这个特定的错误是通过使用 alpha6 解决的,正如上面指出的@Tor Norbye——但后来我出现了这个错误https://code.google.com/p/android/issues/detail?id=195044

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

当他们解决问题时,Instant Run 将是一个非常酷的功能!

回答by Christlin Panneer

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.

我刚刚在 Android Studio 3.3 中遇到了类似的问题;当我通过更改包和应用程序 ID 信息将项目复制到另一个项目时。

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

由于旧应用程序安装在目标设备上,因此以下 2 个选项有效

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

1.清理项目并重新构建(工作)

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

2. 在设备上卸载之前的应用程序(工作中)