新公司注冊(cè)工商核名系統(tǒng)網(wǎng)站優(yōu)化外包
文章目錄
- 配置
- 下載AS
- 編譯
- 源碼依賴導(dǎo)入
- 玩一下andorid.iml
注意:
- 有些時(shí)候發(fā)現(xiàn)為啥自己編譯就這么難呢?不是卡死就無(wú)數(shù)次重啟虛擬機(jī),一切的原罪在配置過(guò)低,換句話說(shuō)就是窮。
- 關(guān)于導(dǎo)入源碼的下載參考 Android Studio for Platform (ASfP) 使用教程
- 內(nèi)存消耗非常驚人!!! 建議編譯內(nèi)存在32G,避免出現(xiàn)卡頓甚至卡死,因?yàn)榧词褂薪粨Q內(nèi)存仍然會(huì)卡頓,如下一共使用到11+8≈20G內(nèi)存之多,加上Ubuntun本地內(nèi)存高達(dá)7G左右,如果是虛擬機(jī)開發(fā),建議直接上64G內(nèi)存。
配置
1. 選擇android.ipr導(dǎo)入源碼
2. 建立一個(gè)空的jdk, 并設(shè)置為工程依賴的jdk
3. 刪除所有的依賴庫(kù)
4. 將frameworks和external目錄作為依賴,并調(diào)整依賴優(yōu)先級(jí)
5. 將out/target/common/R/設(shè)置為依賴
6. 將不需要的目錄從索引中刪除,提高檢索速度**
下載AS
下載
https://developer.android.com/studio/install?hl=zh-tw#linux
3.雙擊解壓到 :/opt/android-studio
創(chuàng)建快捷方式
/usr/share/applications/android-studio.desktop
[Desktop Entry]
Encoding=UTF-8
Name=RealAndroidStudio
Comment=RealAndroidStudio
Exec=/opt/android-studio/bin/studio.sh
Icon=/opt/android-studio/bin/studio.png
Terminal=false
StartupNotify=true
Type=Application
Categories=Application;Development;
編譯
soruce build/envsetup.sh
lunch sdk_phone_x86_64
make -j8
mmm development/tools/idegen/
. development/tools/idegen/idegen.shsudo chmod 777 android.iml
sudo chmod 777 android.ipr
- android.ipr:通常是保存工程相關(guān)的設(shè)置,比如編譯器配置,入口,相關(guān)的libraries等
- android.iml:則是主要是描述了modules,比如modules的路徑,依賴關(guān)系等.
- android.iws:則主要是包含了一些個(gè)人工作區(qū)的設(shè)置.
修改 iml 內(nèi)容
gedit /data/android-11.0.0_r9/android.iml
- 源碼只需要external(第三方依賴),frameworks(框架)
<content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/external" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/frameworks" isTestSource="false" /><excludeFolder url="file://$MODULE_DIR$/.repo" /><excludeFolder url="file://$MODULE_DIR$/abi" /><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$/frameworks/base/docs" /><excludeFolder url="file://$MODULE_DIR$/hardware" /><excludeFolder url="file://$MODULE_DIR$/kernel" /><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$/prebuilt" /><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" /></content>
完成之后,按照上面說(shuō)的步驟,使用Android Studio選中"android.ipr"打開項(xiàng)目即可。
源碼依賴導(dǎo)入
如果之前沒(méi)有刪除orderEntry* 會(huì)出現(xiàn)很多依賴項(xiàng),直接刪除,然后導(dǎo)入frameworks和external源碼依賴*
導(dǎo)入后提示如下
玩一下andorid.iml
1. 我們刪除整個(gè)項(xiàng)目
2. 打開iml 發(fā)現(xiàn)sourceFolder直接消失了,只剩下orderEntry 依賴
3.重新打開Project Structure
4.選擇framework 和packages 發(fā)現(xiàn)右邊多了些Source Folders的源文件
https://blog.csdn.net/ChaoLi_Chen/article/details/121947970
https://juejin.cn/post/6859181913232375815
https://juejin.cn/post/7216495812577427517
https://www.jianshu.com/p/30a628335114
https://blog.csdn.net/qq_20330595/article/details/133764506