简体   繁体   English

Android Studio已签名APK未安装

[英]Android Studio Signed APK Not Installing

I am in Android Studio and signing an APK under Build > Generate Signed APK and using the wizard. 我在Android Studio中并在Build> Generate Signed APK和使用向导下签署APK。 Everything appears to sign fine and an .apk file is generated. 一切似乎都很好,并生成.apk文件。

When I go copy this file over to my device (either Nexus 7 or Moto X) it won't install. 当我将此文件复制到我的设备(Nexus 7或Moto X)时,它将无法安装。 I get an "install failed" message. 我收到“安装失败”消息。

I can't figure out what's going wrong at all. 我无法弄清楚到底出了什么问题。 I have put this .apk up in the google play developer console under "alpha testing" and it was accepted fine (I'm waiting for the tester link to become active to try and download / install from there). 我把这个.apk放在谷歌游戏开发者控制台的“alpha测试”下,它被接受了(我正在等待测试人员链接变得活跃,尝试从那里下载/安装)。

The instructions for the wizard here ( http://developer.android.com/tools/publishing/app-signing.html#studio ) show in the screenshot of the final stage a drop down called "Build Type" selected to "release". 这里向导的说明( http://developer.android.com/tools/publishing/app-signing.html#studio )在最后阶段的屏幕截图中显示一个名为“Build Type”的下拉列表,选择“发布” 。 I don't have that in my version of Android Studio. 我在我的Android Studio版本中没有这个。 There isn't anything I can find in this wizard that will let me specify a "release" build. 我在这个向导中找不到任何可以指定“发布”版本的东西。

Any help anyone can give me would be so much appreciated. 任何人都可以给我的任何帮助将非常感激。 Thanks! 谢谢!

You need to be in release mode to generate a signed APK. 您需要处于发布模式才能生成已签名的APK。 On the lower left corner of your Android Studio should be a tiny square icon. 在Android Studio的左下角应该是一个小方块图标。 Click on it and a menu shall pop up. 点击它,弹出一个菜单。 Now choose Build Variants and you'll get a table with two columns: Module and Build Variant. 现在选择Build Variants,你将获得一个包含两列的表:Module和Build Variant。 There must be debug written below Build Variant. 必须在Build Variant下面编写调试。 Click on it and you will get a dropdown. 点击它,你会得到一个下拉列表。 Now click on release and Gradle will start building the release version. 现在点击发布,Gradle将开始构建发布版本。 Once it is completed generate the signed APK. 一旦完成生成签名的APK。

my 2 cents: with Android Studio 2.3 you can sign an app in two ways: v1 jar signature, v2 full apk signature. 我的2美分:使用Android Studio 2.3,您可以通过两种方式签署应用程序:v1 jar signature,v2 full apk签名。 I was using the v2 option and this caused the signed app to not install on my android device. 我正在使用v2选项,这导致签名的应用程序无法安装在我的Android设备上。 I then unchecked the v2 option, checked the v1 one and the apk now installs as expected. 然后,我取消选中v2选项,检查v1,然后按预期安装apk。

Late to the game but here's something stupid that worked for me: 比赛的后期,但这里有一些对我有用的蠢事:
I had to uninstall the app for all users in Settings>Apps>MyApp 我必须在设置>应用> MyApp中所有用户卸载该应用

If you just uninstall it sometimes just removes it from your account and not the device, so you'd have a version or certificate mismatch when you tried to install the new APK. 如果您只是卸载它,有时只是将其从您的帐户而不是设备中删除,因此当您尝试安装新的APK时,您的版本或证书不匹配。

Hope that helps someone 希望能帮助别人

Yes. 是。 If you have two options before generation signed apk (V1 and V2) you should use V1 jar signature now, because there is no backward compatibility and all android phones with version < 7 won't accept this signature. 如果你在生成签名apk(V1和V2)之前有两个选项,你现在应该使用V1 jar签名,因为没有向后兼容性,所有版本<7的Android手机都不接受这个签名。 Backward compatibility will be added in some next N Developer Preview. 向后兼容性将在下一个N Developer Preview中添加。 See: https://developer.android.com/about/versions/nougat/android-7.0.html#apk_signature_v2 请参阅: https//developer.android.com/about/versions/nougat/android-7.0.html#apk_signature_v2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM