Android 什么是 INSTALL_PARSE_FAILED_NO_CERTIFICATES 错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2914105/
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
What is INSTALL_PARSE_FAILED_NO_CERTIFICATES error?
提问by mtmurdock
I was trying to change my default/main/startup (whatever you call it) activity by editing the androidmanifest.xml
file. All i did was change the android:name
property. however, this completely broke the entire app. when I try to install it fails and reads.
我试图通过编辑androidmanifest.xml
文件来更改我的默认/主/启动(无论你怎么称呼它)活动。我所做的就是改变android:name
财产。然而,这完全破坏了整个应用程序。当我尝试安装它失败并读取时。
Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES
安装错误:INSTALL_PARSE_FAILED_NO_CERTIFICATES
When I tried to change it back to its previous state, it was still giving me the same error... What have I done?
当我试图将它改回以前的状态时,它仍然给我同样的错误......我做了什么?
采纳答案by Dave Webb
Did you edit the AndroidManifest.xml
directly in the .apk
file? If so, that won't work.
你是AndroidManifest.xml
直接在.apk
文件中编辑的吗?如果是这样,那将不起作用。
Every Android .apk
needs to be signed if it is going to be installed on a phone, even if you're not installing through the Market. The development tools work round this by signing with a development certificate but the .apk
is still signed.
.apk
如果要安装在手机上,每个 Android 都需要签名,即使您不是通过 Market 安装。开发工具通过使用开发证书进行签名来解决此问题,但该证书.apk
仍然是签名的。
One use of this is so a device can tell if an .apk
is a valid upgrade for an installed application, since if it is the Certificates will be the same.
这样做的一个用途是,设备可以判断.apk
已安装应用程序的升级是否有效,因为如果是,则证书将相同。
So if you make any changes to your app at all you'll need to rebuild the .apk
so it gets signed properly.
因此,如果您对您的应用程序进行任何更改,您将需要重建它.apk
以便正确签名。
回答by Paul Ratazzi
I found that this error can now also occur when using the wrong signing config. As described here, Android 7.0 introduces a new signature scheme, V2. The V2 scheme signs the entire APK rather than just the JAR, as is done in the V1 scheme. If you sign with only V2, and attempt to install on a pre-7.0 target, you'll get this error since the JARs themselves are not signed and the pre-7.0 PackageManagercannot detect the presence of the V2 APK signature.
我发现现在使用错误的签名配置时也会发生此错误。如上所述这里的Android 7.0引入了一个新的签名方案,V2。V2 方案对整个 APK 进行签名,而不仅仅是对 JAR 进行签名,就像在 V1 方案中所做的那样。如果您只使用 V2 签名,并尝试在 7.0 之前的目标上安装,您将收到此错误,因为 JAR 本身没有签名,并且 7.0 之前的PackageManager无法检测到 V2 APK 签名的存在。
To be compatible with all target systems, make sure the APK is signed with both schemes by checking both signature version boxes in Android Studio's Generate Signed APKdialog as shown here:
为了与所有目标系统兼容,请通过检查 Android Studio 的生成签名 APK对话框中的两个签名版本框来确保 APK 使用两种方案进行签名,如下所示:
If only 7.0 targets are anticipated, then there is no need to include the V1 signature.
如果仅预期 7.0 目标,则无需包含 V1 签名。
回答by Chloe
I found this was caused by my JDK version.
我发现这是由我的 JDK 版本引起的。
I was having this problem with 'ant' and it was due to this CAUTION mentioned in the documentation:
我在使用“ant”时遇到了这个问题,这是由于文档中提到的这个注意事项:
http://developer.android.com/guide/publishing/app-signing.html#signapp
Caution: As of JDK 7, the default signing algorithim has changed, requiring you to specify the signature and digest algorithims (-sigalg and -digestalg) when you sign an APK.
http://developer.android.com/guide/publishing/app-signing.html#signapp
注意:从 JDK 7 开始,默认签名算法已更改,要求您在签名 APK 时指定签名和摘要算法(-sigalg 和 -digestalg)。
I have JDK 7. In my Ant log, I used -v for verbose and it showed
我有 JDK 7。在我的 Ant 日志中,我使用 -v 表示详细信息,它显示
$ ant -Dadb.device.arg=-d -v release install
[signjar] Executing 'C:\Program Files\Java\jdk1.7.0_03\bin\jarsigner.exe' with arguments:
[signjar] '-keystore'
[signjar] 'C:\cygwin\home\Chloe\pairfinder\release.keystore'
[signjar] '-signedjar'
[signjar] 'C:\cygwin\home\Chloe\pairfinder\bin\PairFinder-release-unaligned.apk'
[signjar] 'C:\cygwin\home\Chloe\pairfinder\bin\PairFinder-release-unsigned.apk'
[signjar] 'mykey'
[exec] pkg: /data/local/tmp/PairFinder-release.apk
[exec] Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
I signed the JAR manually and zipaligned it, but it gave a slightly different error:
我手动签署了 JAR 并将其压缩对齐,但它给出了一个略有不同的错误:
$ "$JAVA_HOME"/bin/jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore release.keystore -signedjar bin/PairFinder-release-unaligned.apk bin/PairFinder-release-unsigned.apk mykey
$ zipalign -v -f 4 bin/PairFinder-release-unaligned.apk bin/PairFinder-release.apk
$ adb -d install -r bin/PairFinder-release.apk
pkg: /data/local/tmp/PairFinder-release.apk
Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]
641 KB/s (52620 bytes in 0.080s)
I found that answered here.
我发现这里有答案。
How to deal with INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES without uninstallation
不卸载如何处理INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES
I only needed to uninstall it and then it worked!
我只需要卸载它然后它就可以工作了!
$ adb -d uninstall com.kizbit.pairfinder
Success
$ adb -d install -r bin/PairFinder-release.apk
pkg: /data/local/tmp/PairFinder-release.apk
Success
641 KB/s (52620 bytes in 0.080s)
Now I only need modify the build.xml to use those options when signing!
现在我只需要修改 build.xml 即可在签名时使用这些选项!
Ok here it is: C:\Program Files\Java\android-sdk\tools\ant\build.xml
好的,这里是:C:\Program Files\Java\android-sdk\tools\ant\build.xml
<signjar
sigalg="MD5withRSA"
digestalg="SHA1"
jar="${out.packaged.file}"
signedjar="${out.unaligned.file}"
keystore="${key.store}"
storepass="${key.store.password}"
alias="${key.alias}"
keypass="${key.alias.password}"
verbose="${verbose}" />
回答by JanCor
Most of the time the solution for this error is really simple:
大多数情况下,此错误的解决方案非常简单:
- Uninstall your apk
- Clean your Android project
- Build your Android project
- Install / run your apk
- 卸载你的 apk
- 清理你的 Android 项目
- 构建您的 Android 项目
- 安装/运行你的 apk
回答by Alejadro Xalabarder
solved (for me) using in keytool the args
解决了(对我而言)在 keytool 中使用 args
-sigalg MD5withRSA -keyalg RSA -keysize 1024
and using in jarsigner
并在 jarsigner 中使用
-sigalg MD5withRSA -digestalg SHA1
solution found in
解决方案在
回答by Rajiv Ranjan
I was also facing the same issue. First I generated build using V2 and installed that in mobile devices running on OS 5.1 and I got the same issue. But build was working fine on Tablet running on OS 7.0. So I generated build with V1 Jar signature and it was working fine on both the devices.
我也面临同样的问题。首先,我使用 V2 生成构建并将其安装在运行 OS 5.1 的移动设备中,但我遇到了同样的问题。但是构建在 OS 7.0 上运行的平板电脑上运行良好。所以我用 V1 Jar 签名生成了构建,它在两个设备上都运行良好。
Conclusion:If you are supporting the device below android OS 7.0. Use V1 jar signature to generate the build.
结论:如果您支持 android OS 7.0 以下的设备。使用 V1 jar 签名生成构建。
回答by Kristopher Johnson
In my case, I could build and run release builds, but got the INSTALL_PARSE_FAILED_NO_CERTIFICATES
error when trying to do a debug build.
就我而言,我可以构建和运行发布版本,但INSTALL_PARSE_FAILED_NO_CERTIFICATES
在尝试进行调试版本时出现错误。
The solution was to delete my debug.keystore
file and let ADT recreate it. It had apparently expired.
解决方案是删除我的debug.keystore
文件并让 ADT 重新创建它。显然已经过期了。
A better long-term solution is to explicitly create a debug.keystore
that does not expire after only a year, instead of letting ADT create it. Here is the command to do that:
一个更好的长期解决方案是明确创建一个debug.keystore
仅在一年后不会过期的,而不是让 ADT 创建它。这是执行此操作的命令:
keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 14000
When prompted, enter these values:
出现提示时,输入以下值:
- First and last name: Android Debug
- Organizational unit: Android
- Name of organization: Unknown
- City or Locality: Unknown
- State or Province: Unknown
- Country code: US
- 名字和姓氏:Android 调试
- 组织单位:安卓
- 组织名称:未知
- 城市或地区:未知
- 州或省:未知
- 国家代码:美国
回答by Ixx
This is an ugly but fast solution: use JDK 6 instead of 7.
这是一个丑陋但快速的解决方案:使用 JDK 6 而不是 7。
After read Chloe's answer, I uninstalled my JDK 7 (don't need it currently anyways) and installed JDK 6. That fixed it. A better solution would make ant uses JDK 6 (without uninstalling 7). Maybe possible changing / setting this property:
阅读克洛伊的回答后,我卸载了我的 JDK 7(目前不需要它)并安装了 JDK 6。这修复了它。更好的解决方案是让 ant 使用 JDK 6(无需卸载 7)。也许可以更改/设置此属性:
java.library.path
java.library.path
in local.properties file. It's in the project directory (root).
在 local.properties 文件中。它位于项目目录(根)中。
Android doesn't work with JDK 7 anyways (only 6 or 5), so make that the ant script also uses JDK 6 or 5 is probably a good solution.
Android 无论如何都不能使用 JDK 7(只有 6 或 5),因此使 ant 脚本也使用 JDK 6 或 5 可能是一个很好的解决方案。
回答by Pankaj kumar
Its because previously generated build and current is having conflict in signature version between v1(jar signature) and v2(full APK Signature),
这是因为之前生成的构建版本和当前版本在 v1(jar 签名)和 v2(完整 APK 签名)之间的签名版本存在冲突,
To fix tick proper signature version under Generate Signed APK dialog
在生成签名的 APK 对话框下修复勾选正确的签名版本
回答by Rowland Mtetezi
In newer Android Studio versions 3.2+, if you are trying to run release
install, and you have not defined any signing configurations, it will show the error prompt and install will fail. What you need to do is either run the debug
build or set up the signing configuration (V1 or V2) correctly.
在较新的 Android Studio 3.2+ 版本中,如果您尝试运行release
安装,并且您尚未定义任何签名配置,则会显示错误提示并且安装将失败。您需要做的是正确运行debug
构建或设置签名配置(V1 或 V2)。