我在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的框架后,它永远不会报告这样的错误。这是为什么?