为啥 adb 因失败 [INSTALL_PARSE_FAILED_NO_CERTIFICATES] 而失败?
Posted
技术标签:
【中文标题】为啥 adb 因失败 [INSTALL_PARSE_FAILED_NO_CERTIFICATES] 而失败?【英文标题】:Why does adb fail with Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]?为什么 adb 因失败 [INSTALL_PARSE_FAILED_NO_CERTIFICATES] 而失败? 【发布时间】:2012-04-06 22:12:10 【问题描述】:从“jarsigner -verify”的结果可以看出,我的 apk 确实已签名,但我仍然安装“失败”。任何帮助都会很棒!
carl-emil@carlemil-ThinkPad-T410:~/workspace/myapp$ ~/android-sdk-linux_15/platform-tools/adb install target/myapp-aligned.apk
3857 KB/s (352413 bytes in 0.089s)
pkg: /data/local/tmp/myapp-aligned.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
carl-emil@carlemil-ThinkPad-T410:~/workspace/OVIVO$ jarsigner -verify target/myapp-aligned.apk
jar verified.
carl-emil@carlemil-ThinkPad-T410:~/workspace/myapp$ java -version
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10.2)
OpenJDK Server VM (build 20.0-b11, mixed mode)
carl-emil@carlemil-ThinkPad-T410:~/workspace/myapp$
我正在使用 maven3 构建这个项目,来自 maven 的日志如下所示,在其中找不到任何会导致签名步骤中断的内容。
carl-emil@carlemil-ThinkPad-T410:~/workspace/myapp$ mvn3 clean install -Pmyapp,monkey
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.goldengekko.myapp.selfcare:myapp-selfcare:apk:1.11-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-resources-plugin is missing. @ line 166, column 12
[WARNING] 'build.plugins.plugin.version' for org.codehaus.mojo:build-helper-maven-plugin is missing. @ line 213, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building com.goldengekko.myapp.selfcare:myapp-selfcare 1.11-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://maven.goldengekko.com:8001/nexus/content/groups/public/org/apache/maven/plugins/maven-resources-plugin/maven-metadata.xml
Downloaded: http://maven........maven-metadata.xml (704 B at 0.5 KB/sec)
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ myapp-selfcare ---
[INFO] Deleting /home/carl-emil/workspace/myapp/target
[INFO]
[INFO] --- build-helper-maven-plugin:1.5:parse-version (parse-version) @ myapp-selfcare ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default) @ myapp-selfcare ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 62 resources to res
[INFO] Copying 1 resource to res
[INFO] Copying 1 resource to res/values/
[INFO] Copying 1 resource to /home/carl-emil/workspace/myapp/target/filtered-manifest
[INFO]
[INFO] --- android-maven-plugin:3.1.1:generate-sources (default-generate-sources) @ myapp-selfcare ---
[DEBUG] Expanding: /home/carl-emil/.m2/repository/com/viewpagerindicator/library/2.2.3/library-2.2.3.apklib into /home/carl-emil/workspace/myapp/target/unpack/apklibs/com.viewpagerindicator_library_apklib_2.2.3
[DEBUG] expand complete
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] /home/carl-emil/android-sdk-linux_15/platform-tools/aapt [package, -m, -J, /home/carl-emil/workspace/myapp/target/generated-sources/r, -M, /home/carl-emil/workspace/myapp/target/filtered-manifest/AndroidManifest.xml, -S, /home/carl-emil/workspace/myapp/res, -S, /home/carl-emil/workspace/myapp/target/unpack/apklibs/com.viewpagerindicator_library_apklib_2.2.3/res, --auto-add-overlay, -A, /home/carl-emil/workspace/myapp/assets, -I, /home/carl-emil/android-sdk-linux_15/platforms/android-8/android.jar]
[INFO] /home/carl-emil/android-sdk-linux_15/platform-tools/aapt [package, -m, -J, /home/carl-emil/workspace/myapp/target/generated-sources/r, --custom-package, com.viewpagerindicator, -M, /home/carl-emil/workspace/myapp/target/filtered-manifest/AndroidManifest.xml, -S, /home/carl-emil/workspace/myapp/res, -S, /home/carl-emil/workspace/myapp/target/unpack/apklibs/com.viewpagerindicator_library_apklib_2.2.3/res, --auto-add-overlay, -A, /home/carl-emil/workspace/myapp/assets, -A, /home/carl-emil/workspace/myapp/target/unpack/apklibs/com.viewpagerindicator_library_apklib_2.2.3/assets, -I, /home/carl-emil/android-sdk-linux_15/platforms/android-8/android.jar]
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ myapp-selfcare ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 62 resources to res
[INFO] Copying 1 resource to res
[INFO] Copying 1 resource to res/values/
[INFO] Copying 1 resource to /home/carl-emil/workspace/myapp/target/filtered-manifest
[INFO] skip non existing resourceDirectory /home/carl-emil/workspace/myapp/target/generated-sources/extracted-dependencies/src/main/resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ myapp-selfcare ---
[INFO] Compiling 36 source files to /home/carl-emil/workspace/myapp/target/classes
[INFO]
[INFO] --- maven-antrun-plugin:1.6:run (FixManifest) @ myapp-selfcare ---
[INFO] Executing tasks
main:
inotify_add_watch: No such file or directory
[INFO] Executed tasks
[INFO]
[INFO] registerToSubTree : warning, failed to register /home/carl-emil/workspace/myapp/target/filtered-manifest/rep2865681923253179562.tmp :Error watching /home/carl-emil/workspace/myapp/target/filtered-manifest/rep2865681923253179562.tmp : No such file or directory--- android-maven-plugin:3.1.1:proguard (default-proguard) @ myapp-selfcare ---
inotify_add_watch: No such file or directory
registerToSubTree : warning, failed to register /home/carl-emil/workspace/myapp/target/filtered-manifest/rep244121430022461645.tmp :Error watching /home/carl-emil/workspace/myapp/target/filtered-manifest/rep244121430022461645.tmp : No such file or directory
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ myapp-selfcare ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/carl-emil/workspace/myapp/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ myapp-selfcare ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12:test (default-test) @ myapp-selfcare ---
[INFO] No tests to run.
[INFO] Surefire report directory: /home/carl-emil/workspace/myapp/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- android-maven-plugin:3.1.1:dex (default-dex) @ myapp-selfcare ---
[INFO] /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java [-Xmx1024M, -jar, /home/carl-emil/android-sdk-linux_15/platform-tools/lib/dx.jar, --dex, --output=/home/carl-emil/workspace/myapp/target/classes.dex, /home/carl-emil/.m2/repository/com/viewpagerindicator/library/2.2.3/library-2.2.3.apklib, /home/carl-emil/.m2/repository/android/support.v4/0.0.6/support.v4-0.0.6.jar, /home/carl-emil/.m2/repository/com/googlecode/androidannotations/androidannotations/2.4/androidannotations-2.4-api.jar, /home/carl-emil/workspace/myapp/target/classes, /home/carl-emil/.m2/repository/com/directionalviewpager/library/1.2.0/library-1.2.0.jar, /home/carl-emil/.m2/repository/com/google/code/gson/gson/1.6/gson-1.6.jar, /home/carl-emil/.m2/repository/com/sun/codemodel/codemodel/2.4.1/codemodel-2.4.1.jar]
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ myapp-selfcare ---
[INFO] Building jar: /home/carl-emil/workspace/myapp/target/myapp-selfcare.jar
[INFO]
[INFO] --- android-maven-plugin:3.1.1:apk (default-apk) @ myapp-selfcare ---
[INFO] Copying dependency assets files to combined assets directory.
[INFO] Copying local assets files to combined assets directory.
[INFO] /home/carl-emil/android-sdk-linux_15/platform-tools/aapt [package, -f, -M, /home/carl-emil/workspace/myapp/target/filtered-manifest/AndroidManifest.xml, -S, /home/carl-emil/workspace/myapp/res, -S, /home/carl-emil/workspace/myapp/target/unpack/apklibs/com.viewpagerindicator_library_apklib_2.2.3/res, --auto-add-overlay, -A, /home/carl-emil/workspace/myapp/target/generated-sources/combined-assets/assets, -I, /home/carl-emil/android-sdk-linux_15/platforms/android-8/android.jar, -F, /home/carl-emil/workspace/myapp/target/myapp-selfcare.ap_]
[INFO]
[INFO] --- maven-jarsigner-plugin:1.2:sign (signing) @ myapp-selfcare ---
[INFO] 2 archive(s) processed
[INFO]
[INFO] --- android-maven-plugin:3.1.1:zipalign (alignApk) @ myapp-selfcare ---
[INFO] Running command: /home/carl-emil/android-sdk-linux_15/tools/zipalign
[INFO] with parameters: [-f, 4, /home/carl-emil/workspace/myapp/target/myapp-selfcare.apk, /home/carl-emil/workspace/myapp/target/myapp-selfcare-aligned.apk]
[INFO] Attach /home/carl-emil/workspace/myapp/target/myapp-selfcare-aligned.apk to the project
[INFO]
[INFO] --- android-maven-plugin:3.1.1:internal-pre-integration-test (default-internal-pre-integration-test) @ myapp-selfcare ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO]
[INFO] --- android-maven-plugin:3.1.1:internal-integration-test (default-internal-integration-test) @ myapp-selfcare ---
[INFO] No InstrumentationRunner found - skipping tests
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ myapp-selfcare ---
JNotifyAdapterLinux: warning, recieved event for an unregisted LinuxWD -1 ignoring...
JNotifyAdapterLinux: warning, recieved event for an unregisted LinuxWD -1 ignoring...
JNotifyAdapterLinux: warning, recieved event for an unregisted LinuxWD -1 ignoring...
[INFO] Installing /home/carl-emil/workspace/myapp/target/myapp-selfcare.apk to /home/carl-emil/.m2/repository/com/goldengekko/myapp/selfcare/myapp-selfcare/1.11-SNAPSHOT/myapp-selfcare-1.11-SNAPSHOT.apk
[INFO] Installing /home/carl-emil/workspace/myapp/pom.xml to /home/carl-emil/.m2/repository/com/goldengekko/myapp/selfcare/myapp-selfcare/1.11-SNAPSHOT/myapp-selfcare-1.11-SNAPSHOT.pom
[INFO] Installing /home/carl-emil/workspace/myapp/target/myapp-selfcare.jar to /home/carl-emil/.m2/repository/com/goldengekko/myapp/selfcare/myapp-selfcare/1.11-SNAPSHOT/myapp-selfcare-1.11-SNAPSHOT.jar
[INFO] Installing /home/carl-emil/workspace/myapp/target/myapp-selfcare-aligned.apk to /home/carl-emil/.m2/repository/com/goldengekko/myapp/selfcare/myapp-selfcare/1.11-SNAPSHOT/myapp-selfcare-1.11-SNAPSHOT-aligned.apk
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.769s
[INFO] Finished at: Fri Mar 23 08:59:37 UTC 2012
[INFO] Final Memory: 13M/64M
[INFO] ------------------------------------------------------------------------
【问题讨论】:
是的,只粘贴了日志签名部分周围的行。 现在我从 maven 添加了完整的日志。我应该在此处添加其他任何相关内容以使我的问题更清楚吗?谢谢! Maven 日志对我来说看起来很正常。您是推送安装到模拟器还是真实设备? 跟随official dev guide,并确保您的密钥库文件已正确生成。 好的,将尝试生成一个新的密钥库,感谢到目前为止的帮助! 【参考方案1】:找到了!我在使用“ant”时遇到了这个问题,这是由于文档中提到的这个 CAUTION:
http://developer.android.com/guide/publishing/app-signing.html#signapp
注意:从 JDK 7 开始,默认签名算法已更改,要求您在签名 APK 时指定签名和摘要算法(-sigalg 和 -digestalg)。
我有 JDK 7。我不能代表您的 OpenJDK IcedTea,但这可能是同一个问题。您的 Maven 日志没有提供足够的详细信息。在我的 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]
我手动签署了 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)
我在这里找到了答案。
How to deal with INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES without uninstallation
我只需要卸载它就可以了!
$ 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)
现在我只需要修改 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" />
【讨论】:
【参考方案2】:我在 MonoDevelop 中使用 debug[microsoft.net] 配置构建应用程序。现在可以正常使用了。
【讨论】:
【参考方案3】:按照here 的建议,至少使用 Ant 1.8.3 并将这个 sn-p 放入您的 ant 文件中:
<presetdef name="signjar">
<signjar sigalg="MD5withRSA" digestalg="SHA1" />
</presetdef>
【讨论】:
【参考方案4】:就我而言,我可以构建并运行发布版本,但在尝试进行调试构建时出现INSTALL_PARSE_FAILED_NO_CERTIFICATES
错误。
解决方案是删除我的debug.keystore
文件并让构建系统重新创建它。
【讨论】:
【参考方案5】:对于遇到类似问题的其他人 - 我有同样的错误,但它似乎不是签名算法。我只需要使用 Java 1.6 中的 jarsigner。我使用的签名算法似乎对两者都相同:dsaWithSHA1,但 1.6 有效,而 1.7 无效。
【讨论】:
以上是关于为啥 adb 因失败 [INSTALL_PARSE_FAILED_NO_CERTIFICATES] 而失败?的主要内容,如果未能解决你的问题,请参考以下文章