我已经生成了一个仅包含onCreate()
的小型测试应用。我可以通过adb install
在我模拟的Nexus 7上安装它就好了。但是,使用apktool decode
对其进行解码并通过apktool build -c
重建(-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
答案 0 :(得分:0)
不是-c选项仅在" build"上有效吗?
阅读apktool wiki,你可以阅读:
在[d] ecode之后,解码的apk文件夹中会有新的文件夹(原始/未知)
- original = META-INF文件夹/ AndroidManifest.xml,需要保留apks的签名以防止需要辞职。 <强>二手 在[b] uild
上使用-c / --copy-original
所以我认为命令的正确语法是:
apktool b -c folder
我从未尝试过,所以我不是百分百肯定。