Android 4.0 framework源码修改编译,模拟器运行不起来

我是用的android 4.0.3 ICS的源码,编译好后,利用编译好的镜像启动的模拟器,以前修改过里面的Launcher,将生成的Launcher.apk和Launcher.odex  push后是成功的。 现在我在

frameworks/base/policy/src/com/android/internal/policy/impl/LockScreen.java

frameworks/base/core/java/com/android/internal/widget/multiwaveview/MultiWaveView.java

中加了一点log,其实就是解锁时相应的输出坐标等信息,

试了两种方法:

1. make framework  
  make snod

2.  在framework/base中mm
  adb push framework.jar 和 framework.odex 到 system/framework/

结果都是在启动模拟器时,在开机显示 android字样时进不去了,ddms中不停的打印如下信息:

07-30 06:50:52.762: I/ServiceManager(30): service 'media.audio_policy' died
07-30 06:50:52.762: I/ServiceManager(30): service 'media.audio_flinger' died
07-30 06:50:52.762: I/ServiceManager(30): service 'media.player' died
07-30 06:50:52.762: I/ServiceManager(30): service 'media.camera' died
07-30 06:50:52.822: I/Netd(383): Netd 1.0 starting
07-30 06:50:52.842: E/Netd(383): Unable to bind netlink socket: No such file or directory
07-30 06:50:52.842: E/Netd(383): Unable to open quota2 logging socket
07-30 06:50:53.253: I/(381): ServiceManager: 0xf958
07-30 06:50:53.253: I/AudioFlinger(381): Loaded primary audio interface from LEGACY Audio HW HAL (audio)
07-30 06:50:53.253: I/AudioFlinger(381): Using 'LEGACY Audio HW HAL' (audio.primary) as the primary audio interface
07-30 06:50:53.253: D/AudioHardwareInterface(381): setMode(NORMAL)
07-30 06:50:53.253: I/CameraService(381): CameraService started (pid=381)
07-30 06:50:53.262: D/EmulatedCamera_QemuClient(381): Emulated camera list: 
07-30 06:50:53.262: D/EmulatedCamera_FakeCamera(381): Initialize: Fake camera is facing back
07-30 06:50:53.262: V/EmulatedCamera_Factory(381): 1 cameras are being emulated. Fake camera ID is 0
07-30 06:50:53.272: I/AudioFlinger(381): AudioFlinger's thread 0x10fb0 ready to run
07-30 06:50:53.272: W/AudioFlinger(381): Thread AudioOut_1 cannot connect to the power manager service
07-30 06:50:53.272: I/AudioPolicyService(381): Loaded audio policy from LEGACY Audio Policy HAL (audio_policy)
07-30 06:50:56.022: D/AndroidRuntime(393): >>>>>> AndroidRuntime START com.android.internal.os.ZygoteInit <<<<<<
07-30 06:50:56.022: D/AndroidRuntime(393): CheckJNI is ON
07-30 06:50:56.042: I/dalvikvm(393): DexOpt: mismatch dep signature for '/system/framework/framework.odex'
07-30 06:50:56.042: E/dalvikvm(393): /system/framework/android.policy.jar odex has stale dependencies
07-30 06:50:56.042: I/dalvikvm(393): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
07-30 06:50:56.042: D/dalvikvm(393): Unable to process classpath element '/system/framework/android.policy.jar'
07-30 06:50:56.042: I/dalvikvm(393): DexOpt: Some deps went away
07-30 06:50:56.042: E/dalvikvm(393): /system/framework/services.jar odex has stale dependencies
07-30 06:50:56.042: I/dalvikvm(393): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
07-30 06:50:56.042: D/dalvikvm(393): Unable to process classpath element '/system/framework/services.jar'
07-30 06:50:56.042: I/dalvikvm(393): DexOpt: mismatch dep signature for '/system/framework/framework.odex'
07-30 06:50:56.042: E/dalvikvm(393): /system/framework/apache-xml.jar odex has stale dependencies
07-30 06:50:56.042: I/dalvikvm(393): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
07-30 06:50:56.042: D/dalvikvm(393): Unable to process classpath element '/system/framework/apache-xml.jar'
07-30 06:50:56.042: I/dalvikvm(393): DexOpt: mismatch dep signature for '/system/framework/framework.odex'
07-30 06:50:56.042: E/dalvikvm(393): /system/framework/filterfw.jar odex has stale dependencies
07-30 06:50:56.042: I/dalvikvm(393): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory
07-30 06:50:56.042: D/dalvikvm(393): Unable to process classpath element '/system/framework/filterfw.jar'
07-30 06:50:56.682: E/JNIHelp(393): Native registration unable to find class 'com/android/server/Watchdog', aborting

07-30 06:50:56.682: A/libc(393): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)

后来根据高手的提示,去看 build/core/main.mk,发现里面有个droidcore命令,

尝试使用make droidcore编译后,模拟器成功运行,并打印出修改的log,后来仔细分析droidcore:

755 .PHONY: droidcore

756 droidcore: files \
757     systemimage \
758     $(INSTALLED_BOOTIMAGE_TARGET) \
759     $(INSTALLED_RECOVERYIMAGE_TARGET) \
760     $(INSTALLED_USERDATAIMAGE_TARGET) \
761     $(INSTALLED_FILES_FILE)
发现一开始是执行systemimage,于是我又尝试用make systemimage来编译:
修改framework中源码,在framework/base 中mm,退至源码根目录,make systemimage后,启动模拟器,修改效果成功显示。
Ps:
1.貌似执行make snod(systemimage no dependence)不行,看来要编上dependence才行。
2.在make systemimage 之后一定要关闭模拟器重开才行,执行adb shell stop,adb shell start也不行。

就是时间比较长,编一下要10分钟左右。







这个解决方法貌似不错:http://blog.csdn.net/cqupt_chen/article/details/8166090

修复framework代码之后,push编译好的framework.jar和相应的odex文件,发现开机失败,一直在android界面循环

而且不停打dismatch dep :

[plain]  view plain copy
  1. I/dalvikvm(  375): DexOpt: mismatch dep signature for '/system/framework/framework.odex'                   
  2. E/dalvikvm(  375): /system/framework/android.policy.jar odex has stale dependencies                        
  3. I/dalvikvm(  375): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory   
  4. D/dalvikvm(  375): Unable to process classpath element '/system/framework/android.policy.jar'              
  5. I/dalvikvm(  375): DexOpt: mismatch dep signature for '/system/framework/framework.odex'                   
  6. E/dalvikvm(  375): /system/framework/services.jar odex has stale dependencies                              
  7. I/dalvikvm(  375): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory   
  8. D/dalvikvm(  375): Unable to process classpath element '/system/framework/services.jar'                    
  9. I/dalvikvm(  375): DexOpt: mismatch dep signature for '/system/framework/framework.odex'                   
  10. E/dalvikvm(  375): /system/framework/apache-xml.jar odex has stale dependencies                            
  11. I/dalvikvm(  375): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory   
  12. D/dalvikvm(  375): Unable to process classpath element '/system/framework/apache-xml.jar'                  
  13. I/dalvikvm(  375): DexOpt: mismatch dep signature for '/system/framework/framework.odex'                   
  14. E/dalvikvm(  375): /system/framework/filterfw.jar odex has stale dependencies                              
  15. I/dalvikvm(  375): Zip is good, but no classes.dex inside, and no valid .odex file in the same directory   
  16. D/dalvikvm(  375): Unable to process classpath element '/system/framework/filterfw.jar'                    
  17. E/JNIHelp (  375): Native registration unable to find class 'com/android/server/Watchdog', aborting        
  18. F/libc    (  375): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)                                        
在源码中定位到错误地点(DexPrepare.cpp中)

[cpp]  view plain copy
  1. if (len != storedStrLen ||  
  2.     strcmp(cacheFileName, (const char*) ptr) != 0)  
  3. {  
  4.     LOGI("DexOpt: mismatch dep name: '%s' vs. '%s'",  
  5.         cacheFileName, ptr);  
  6.     goto bail;  
  7. }  
  8.   
  9. ptr += storedStrLen;  
  10.   
  11. if (memcmp(signature, ptr, kSHA1DigestLen) != 0) {  
  12.     LOGI("DexOpt: mismatch dep signature for '%s'", cacheFileName);  
  13.     goto bail;  
  14. }  
  15. ptr += kSHA1DigestLen;  
  16.   
  17. LOGV("DexOpt: dep match on '%s'", cacheFileName);  
  18.   
  19. numDeps--;  
看来是依赖签名匹配失败.

如此看来只有两种解决办法:

1.用make snod命令重新编译system.img,这样编译出来的system中的架包之间没有依赖

2.修改DexPrepare.cpp中的验证代码,直接跳过签名验证

你可能感兴趣的:(Android 4.0 framework源码修改编译,模拟器运行不起来)