1

我生成了一个小型测试应用程序,仅包含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
4

1 回答 1

0

-c 选项不是仅对“构建”有效吗?

阅读 apktool wiki,您可以阅读:

[d]ecode后,解码后的apk文件夹中会有新的文件夹(原始/未知)

  • original = META-INF文件夹/AndroidManifest.xml,需要保留apks的签名,防止需要辞职。在 [b]uild 上与 -c / --copy-original 一起使用

所以我认为该命令的正确语法是:

apktool b -c folder

我从来没有尝试过,所以我不能 100% 确定。

于 2016-03-11T14:05:02.740 回答