我无法在 Intermec 设备(运行Android 4.2)上安装我使用SHA-256签名的APK。 我可以在Nexus 5(运行Android 6.0)上安装完全相同的APK。 我已经检查了两个设备,两个设备确实支持SHA-256。
我得到的错误是:
C:\work\n\apks>adb install marlin-app-android-01.00.TRUNK-SNAPSHOT.apk
5136 KB/s (9431036 bytes in 1.793s)
pkg: /data/local/tmp/marlin-app-android-01.00.TRUNK-SNAPSHOT.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
我使用此命令对APK进行签名(使用JDK6):
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore nemo.keystore marlin-app-android-01.00.TRUNK-SNAPSHOT.apk NEMO
当我尝试将APK安装到Intermec时,我得到了这个logcat输出:
10-15 11:19:50.550 416-435/? W/ActivityManager﹕ No content provider found for permission revoke: file:///data/local/tmp/marlin-app-android-01.00.TRUNK-SNAPSHOT.apk
10-15 11:19:50.612 416-435/? W/ActivityManager﹕ No content provider found for permission revoke: file:///data/local/tmp/marlin-app-android-01.00.TRUNK-SNAPSHOT.apk
10-15 11:19:50.784 416-435/? W/PackageParser﹕ Exception reading AndroidManifest.xml in /data/app/vmdl381788980.tmp
java.lang.SecurityException: META-INF/NEMO.SF has invalid digest for res/drawable-mdpi-v4/notification.png in /data/app/vmdl381788980.tmp
at java.util.jar.JarVerifier.invalidDigest(JarVerifier.java:134)
at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:364)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:271)
at java.util.jar.JarFile.getInputStream(JarFile.java:398)
at android.content.pm.PackageParser.loadCertificates(PackageParser.java:446)
at android.content.pm.PackageParser.collectCertificates(PackageParser.java:637)
at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:7886)
at com.android.server.pm.PackageManagerService.access$1900(PackageManagerService.java:172)
at com.android.server.pm.PackageManagerService$5.run(PackageManagerService.java:6018)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.os.HandlerThread.run(HandlerThread.java:60)
10-15 11:19:50.784 416-435/? E/PackageParser﹕ Package ch.post.it.nemo.marlin has no certificates at entry AndroidManifest.xml; ignoring!
显然该文件存在问题:res / drawable-mdpi-v4 / notification.png
接下来,我使用此命令验证了签名:
C:\work\n\apks>jarsigner -verify -verbose -certs marlin-app-android-01.00.TRUNK-SNAPSHOT.apk
得到了这个输出(摘录):
46162 Thu Oct 15 10:52:26 CEST 2015 META-INF/MANIFEST.MF
33900 Thu Oct 15 10:52:26 CEST 2015 META-INF/NEMO.SF
1322 Thu Oct 15 10:52:26 CEST 2015 META-INF/NEMO.RSA
sm 43636 Thu Oct 15 08:49:12 CEST 2015 AndroidManifest.xml
X.509, CN=Nemo, OU=IT12, O=Swiss Post, L=Bern, ST=BE, C=CH
[certificate is valid from 24.06.13 10:59 to 09.11.40 09:59]
sm 113713 Thu Oct 15 08:49:12 CEST 2015 res/drawable-mdpi-v4/notification.png
X.509, CN=Nemo, OU=IT12, O=Swiss Post, L=Bern, ST=BE, C=CH
[certificate is valid from 24.06.13 10:59 to 09.11.40 09:59]
sm 1270 Thu Oct 15 08:49:12 CEST 2015 res/drawable-xhdpi-v11/fa_envelope.png
X.509, CN=Nemo, OU=IT12, O=Swiss Post, L=Bern, ST=BE, C=CH
[certificate is valid from 24.06.13 10:59 to 09.11.40 09:59]
sm 1255 Thu Oct 15 08:49:12 CEST 2015 res/drawable-xhdpi-v11/ic_stat_check.png
X.509, CN=Nemo, OU=IT12, O=Swiss Post, L=Bern, ST=BE, C=CH
[certificate is valid from 24.06.13 10:59 to 09.11.40 09:59]
那里列出了notification.png文件,似乎没问题。
我注意到NEMO.SF和NEMO.RSA在APK中似乎是一个二重奏,在其他一些帖子中,人们建议删除其中一个并重新签名APK。我已经这样做了,但它没有任何帮助。
我已经尝试了所有可以找到的东西。到目前为止没有运气。感谢您提供任何帮助和建议。