为什么adb因失败而失败[INSTALL_PARSE_FAILED_NO_CERTIFICATES]?

时间:2012-03-22 10:48:50

标签: android maven install adb sign

从“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] ------------------------------------------------------------------------

5 个答案:

答案 0 :(得分:16)

发现它!我遇到了'ant'这个问题,这是由于文档中提到的这个注意事项:

  

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并对其进行了zipaligned,但它给出了一个稍微不同的错误:

$ "$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}" />

答案 1 :(得分:2)

正如建议here至少使用Ant 1.8.3并将此代码段放到您的ant文件中:

<presetdef name="signjar">
  <signjar sigalg="MD5withRSA" digestalg="SHA1" />
</presetdef>

答案 2 :(得分:1)

我使用MonoDevelop中的debug [microsoft.net]配置构建应用程序。现在它工作正常。

答案 3 :(得分:0)

就我而言,我可以构建并运行发布版本,但在尝试进行调试构建时遇到INSTALL_PARSE_FAILED_NO_CERTIFICATES错误。

解决方案是删除我的debug.keystore文件,让构建系统重新创建它。

答案 4 :(得分:0)

对于遇到类似问题的其他人 - 我有同样的错误,但它似乎不是签名算法。我只需要使用Java 1.6中的jarsigner。我使用的签名算法似乎是相同的:dsaWithSHA1,但1.6工作,1.7没有。