來(lái)點(diǎn)前奏說(shuō)明
當(dāng)你打開(kāi)這個(gè)文檔的時(shí)候残腌,你已經(jīng)做好準(zhǔn)備了叠艳,話(huà)不多說(shuō)開(kāi)搞烁登。前提你得有源碼职烧,源碼參考
Android源碼開(kāi)發(fā)篇(一)9.0/10.0源碼下載 編譯 刷機(jī)
在Android升級(jí)到P之后,Google默認(rèn)強(qiáng)制打開(kāi)了pre-odex防泵,導(dǎo)致本地調(diào)試的時(shí)候修改fw代碼push之后不work或者開(kāi)不了機(jī)器蚀之。原因在于打開(kāi)pre-odex的情況下,對(duì)于bootclasspath系統(tǒng)會(huì)默認(rèn)生成oat/art/vdex等文件捷泞,這些jar包之間相互依賴(lài)足删,耦合非常高。一旦修改push輕則不work锁右,重則系統(tǒng)出現(xiàn)未知的異常失受。
這對(duì)于本地編譯rom的調(diào)試帶來(lái)極大不便,這里提供一些方案盡量減少本地編譯的時(shí)間咏瑟,方便push調(diào)試拂到。
1、關(guān)閉pre-odex開(kāi)關(guān)
A 修改以下文件
build/core/board_config.mk
build/core/dex_preopt_config.mk
diff --git a/core/board_config.mk b/core/board_config.mk
index ac0f27da53..ea1999590e 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -97,7 +97,13 @@ _board_strip_readonly_list += $(_build_broken_var_list)
# Conditional to building on linux, as dex2oat currently does not work on darwin.
ifeq ($(HOST_OS),linux)
# zhangbin mod start
# 支持通過(guò)export WITH_DEXPREOPT=false 來(lái)關(guān)閉preopt
# WITH_DEXPREOPT := true
ifeq ($(WITH_DEXPREOPT),)
WITH_DEXPREOPT := true
endif
# zhangbin mod end
endif
# ###############################################################
diff --git a/core/dex_preopt_config.mk b/core/dex_preopt_config.mk
index b5834b08b3..53a4273944 100644
--- a/core/dex_preopt_config.mk
+++ b/core/dex_preopt_config.mk
@@ -37,7 +37,7 @@ ifeq ($(HOST_OS),linux)
ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
ifneq (true,$(WITH_DEXPREOPT))
ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
# zhangbin del end
# $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds)
# zhangbin del end
endif
endif
endif
source build/envsetup.sh
lunch aosp_sailfish-userdebug
B 配置如下宏關(guān)閉pre-odex
export WITH_DEXPREOPT=false
編譯framework.jar和services.jar
make framework -j8 && make services -j8
在aosp/out/target/product/sailfish/system/framework目錄下
adb root
adb remount
adb disable-verity
adb reboot
adb root
adb remount
adb push framework.jar system/framework/
如何驗(yàn)證framework.jar 是否成功和有效
我的做法修改LayoutInflater.java文件的
DEBUG修改為true
過(guò)濾LayoutInflater 這個(gè)關(guān)鍵字 隨機(jī)打開(kāi)應(yīng)用一般都會(huì)打印log的 如果輸出了就成功了 之后繼續(xù)搞起來(lái)吧码泞。兄旬。。
如何驗(yàn)證services.jar 是否成功和有效
adb root
adb remount
adb disable-verity
adb reboot
adb root
adb remount
adb push services.jar system/framework/
我的做法修改WindowManagerDebugConfig.java文件的
DEBUG_ANIM修改為true
過(guò)濾Loading animations這個(gè)關(guān)鍵字 隨機(jī)打開(kāi)應(yīng)用一般都會(huì)打印log的 如果和我類(lèi)似就成功了 之后繼續(xù)搞起來(lái)吧余寥。领铐。。
源碼導(dǎo)入Studio
source build/envsetup.sh
lunch aosp_sailfish-userdebug
mmm development/tools/idegen/
development/tools/idegen/idegen.sh
會(huì)在根目錄下面生成android.ipr和android.iml
過(guò)濾一些模塊
如果把Android所有的源碼全部導(dǎo)入到Android Studio里面去宋舷,工程將會(huì)非常大绪撵,而且會(huì)很耗時(shí)間,那么我們就可以把不需要的模塊給過(guò)濾掉祝蝠。
打開(kāi)android.iml文件音诈,加入以下代碼,修改excludeFolder的配置:
<excludeFolder url="file://$MODULE_DIR$/.repo"/>
<excludeFolder url="file://$MODULE_DIR$/abi"/>
<excludeFolder url="file://$MODULE_DIR$/frameworks/base/docs"/>
<excludeFolder url="file://$MODULE_DIR$/art"/>
<excludeFolder url="file://$MODULE_DIR$/bionic"/>
<excludeFolder url="file://$MODULE_DIR$/bootable"/>
<excludeFolder url="file://$MODULE_DIR$/build"/>
<excludeFolder url="file://$MODULE_DIR$/cts"/>
<excludeFolder url="file://$MODULE_DIR$/dalvik"/>
<excludeFolder url="file://$MODULE_DIR$/developers"/>
<excludeFolder url="file://$MODULE_DIR$/development"/>
<excludeFolder url="file://$MODULE_DIR$/device"/>
<excludeFolder url="file://$MODULE_DIR$/docs"/>
<excludeFolder url="file://$MODULE_DIR$/external"/>
<excludeFolder url="file://$MODULE_DIR$/hardware"/>
<excludeFolder url="file://$MODULE_DIR$/kernel-3.18"/>
<excludeFolder url="file://$MODULE_DIR$/libcore"/>
<excludeFolder url="file://$MODULE_DIR$/libnativehelper"/>
<excludeFolder url="file://$MODULE_DIR$/ndk"/>
<excludeFolder url="file://$MODULE_DIR$/out"/>
<excludeFolder url="file://$MODULE_DIR$/pdk"/>
<excludeFolder url="file://$MODULE_DIR$/platform_testing"/>
<excludeFolder url="file://$MODULE_DIR$/prebuilts"/>
<excludeFolder url="file://$MODULE_DIR$/rc_projects"/>
<excludeFolder url="file://$MODULE_DIR$/sdk"/>
<excludeFolder url="file://$MODULE_DIR$/system"/>
<excludeFolder url="file://$MODULE_DIR$/tools"/>
<excludeFolder url="file://$MODULE_DIR$/trusty"/>
<excludeFolder url="file://$MODULE_DIR$/vendor"/>
然后File -> Open---android.ipr 等待一大會(huì) 性能低的可能會(huì)卡住