我生成了一个小型测试应用程序,仅包含onCreate()
. 我可以将它安装在我模拟的 Nexus 7 上adb install
。但是,使用 (-c to copy signature) 对其进行解码apktool decode
和重建apktool build -c
会产生一个无法安装的 apk:
➜ ApkToolTesting adb install justoncreate/dist/justoncreate.apk
1227 KB/s (1145010 bytes in 0.910s)
pkg: /data/local/tmp/justoncreate.apk
Failure [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION]
这次失败的原因可能是什么?在组装过程中肯定丢失了其他东西。
编辑:可能是相关的logcat
输出:
03-09 17:12:49.129 1946 1958 D DefContainer: Copying /data/local/tmp/justoncreate.apk to base.apk
03-09 17:12:49.167 1302 1326 W PackageManager: Failed collect during installPackageLI
03-09 17:12:49.167 1302 1326 W PackageManager: android.content.pm.PackageParser$PackageParserException: Failed reading res/color/abc_primary_text_material_light.xml in java.util.jar.StrictJarFile@a55736e
03-09 17:12:49.167 1302 1326 W PackageManager: at android.content.pm.PackageParser.loadCertificates(PackageParser.java:600)
03-09 17:12:49.167 1302 1326 W PackageManager: at android.content.pm.PackageParser.collectCertificates(PackageParser.java:1102)
03-09 17:12:49.167 1302 1326 W PackageManager: at android.content.pm.PackageParser.collectCertificates(PackageParser.java:1057)
03-09 17:12:49.167 1302 1326 W PackageManager: at com.android.server.pm.PackageManagerService.installPackageLI(PackageManagerService.java:12196)
03-09 17:12:49.167 1302 1326 W PackageManager: at com.android.server.pm.PackageManagerService.-wrap25(PackageManagerService.java)
03-09 17:12:49.167 1302 1326 W PackageManager: at com.android.server.pm.PackageManagerService$9.run(PackageManagerService.java:10156)
03-09 17:12:49.167 1302 1326 W PackageManager: at android.os.Handler.handleCallback(Handler.java:739)
03-09 17:12:49.167 1302 1326 W PackageManager: at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 17:12:49.167 1302 1326 W PackageManager: at android.os.Looper.loop(Looper.java:148)
03-09 17:12:49.167 1302 1326 W PackageManager: at android.os.HandlerThread.run(HandlerThread.java:61)
03-09 17:12:49.167 1302 1326 W PackageManager: at com.android.server.ServiceThread.run(ServiceThread.java:46)
03-09 17:12:49.167 1302 1326 W PackageManager: Caused by: java.lang.SecurityException: META-INF/MANIFEST.MF has invalid digest for res/color/abc_primary_text_material_light.xml in res/color/abc_primary_text_material_light.xml
03-09 17:12:49.167 1302 1326 W PackageManager: at java.util.jar.JarVerifier.invalidDigest(JarVerifier.java:140)
03-09 17:12:49.167 1302 1326 W PackageManager: at java.util.jar.JarVerifier.-wrap0(JarVerifier.java)
03-09 17:12:49.167 1302 1326 W PackageManager: at java.util.jar.JarVerifier$VerifierEntry.verify(JarVerifier.java:132)
03-09 17:12:49.167 1302 1326 W PackageManager: at java.util.jar.JarFile$JarFileInputStream.read(JarFile.java:117)
03-09 17:12:49.167 1302 1326 W PackageManager: at android.content.pm.PackageParser.readFullyIgnoringContents(PackageParser.java:5113)
03-09 17:12:49.167 1302 1326 W PackageManager: at android.content.pm.PackageParser.loadCertificates(PackageParser.java:597)
03-09 17:12:49.167 1302 1326 W PackageManager: ... 10 more