標籤:android blog class code java tar
android編譯framework架包運行報錯
http://blog.csdn.net/cqupt_chen/article/details/8163632
最近在看frameworks裡的源碼,手癢了,便想改改看看效果,沒想到改完後,模擬器卻運行不起來了。
首先聲明,我是用的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分鐘左右。