我修改了Android框架(Android 4.2)中PackageManagerService.java中的一些代码。在make之后,启动模拟器,它会报告以下错误:
10-05 08:20:34.213: I/dalvikvm(575): DexOpt: mismatch dep signature for '/system/framework/core.odex'
10-05 08:20:34.213: E/dalvikvm(575): /system/app/PackageInstaller.apk odex has stale dependencies
10-05 08:20:34.213: E/dalvikvm(575): odex source not available -- failing
10-05 08:20:34.223: W/PackageManager(575): StaleDexCacheError when reading apk: /system/app/PackageInstaller.apk
10-05 08:20:34.223: W/PackageManager(575): dalvik.system.StaleDexCacheError: /system/app/PackageInstaller.apk
10-05 08:20:34.223: W/PackageManager(575): at dalvik.system.DexFile.isDexOptNeeded(Native Method)
10-05 08:20:34.223: W/PackageManager(575): at com.android.server.pm.PackageManagerService.performDexOptLI(PackageManagerService.java:3375)
10-05 08:20:34.223: W/PackageManager(575): at com.android.server.pm.PackageManagerService.scanPackageLI(PackageManagerService.java:3960)
10-05 08:20:34.223: W/PackageManager(575): at com.android.server.pm.PackageManagerService.scanPackageLI(PackageManagerService.java:3238)
10-05 08:20:34.223: W/PackageManager(575): at com.android.server.pm.PackageManagerService.scanDirLI(PackageManagerService.java:3017)
10-05 08:20:34.223: W/PackageManager(575): at com.android.server.pm.PackageManagerService.<init>(PackageManagerService.java:1058)
10-05 08:20:34.223: W/PackageManager(575): at com.android.server.pm.PackageManagerService.main(PackageManagerService.java:837)
10-05 08:20:34.223: W/PackageManager(575): at com.android.server.ServerThread.run(SystemServer.java:177)
如果我清理然后再完成整个项目,它就可以了。但它会在另一次修改后报告相同的错误。由于再次完整构建将持续很长时间,我更喜欢其他解决方案。
我注意到DexPrepare.cpp中的代码:
if (memcmp(signature, ptr, kSHA1DigestLen) != 0) {
LOGI("DexOpt: mismatch dep signature for '%s'", cacheFileName);
goto bail;
}
如果删除这些代码行,它将起作用。我曾经在Android 2.3上工作,并且在Android 2.3(Gingerbread)中仍然存在签名检查,但在对Gingerbread的框架进行修改后,它将永远不会报告此类错误。那是为什么?
答案 0 :(得分:1)
我最后通过明确地运行make droidcore
解决了这个问题。
答案 1 :(得分:0)
我认为在自定义ROM的构建和闪存期间,您不会清理数据和缓存图像。在这种情况下,在这些图像中存储了odexed core.jar
的旧版本,并且在启动期间,Android尝试将新版本与旧版本进行比较。因此,当您进行一些修改时,签名是不同的。