使用WSL搭建環(huán)境需要特別注意的幾點(diǎn)
如下幾點(diǎn)需要在解壓完“aosp-latest.tar”之后和repo sync之前操作焙蹭。
- 設(shè)置aosp源碼所在路徑為大小寫敏感,win10系統(tǒng)支持新建的子目錄繼承父目錄的大小寫敏感特性剥纷,所以只需要設(shè)置aosp根目錄大小寫敏感,參考命令如下(在cmd窗口執(zhí)行,路徑替換為自己實(shí)際的aosp路徑):
fsutil.exe file SetCaseSensitiveInfo D:\07.workspace\aosp enable
-
設(shè)置D:\07.workspace\aosp的所有用戶為“完全控制”權(quán)限
主要參考以下博文
Ubentu編譯Android源碼(AOSP)
win10搭建閱讀Android源碼環(huán)境
編譯命令和過(guò)程如下
- 切換到aosp主目錄執(zhí)行初始化環(huán)境命令:
andy@andy-PC:/mnt/d/07.workspace$ cd aosp/
andy@andy-PC:/mnt/d/07.workspace/aosp$ source build/envsetup.sh
- 執(zhí)行l(wèi)unch并選擇編譯的目標(biāo)版本喳逛,這里選擇25,即“25. aosp_x86_64-eng”
說(shuō)明:如果你的電腦是64位的話管跺,選擇25义黎,因?yàn)閤86版本的虛擬機(jī)運(yùn)行比較快。不要編譯arm 版本的了豁跑,運(yùn)行起來(lái)太慢廉涕,而且運(yùn)行不起來(lái)。
andy@andy-PC:/mnt/d/07.workspace/aosp$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_blueline-userdebug
4. aosp_bonito-userdebug
5. aosp_car_arm-userdebug
6. aosp_car_arm64-userdebug
7. aosp_car_x86-userdebug
8. aosp_car_x86_64-userdebug
9. aosp_cf_arm64_auto-userdebug
10. aosp_cf_arm64_phone-userdebug
11. aosp_cf_x86_64_phone-userdebug
12. aosp_cf_x86_auto-userdebug
13. aosp_cf_x86_phone-userdebug
14. aosp_cf_x86_tv-userdebug
15. aosp_coral-userdebug
16. aosp_coral_car-userdebug
17. aosp_crosshatch-userdebug
18. aosp_crosshatch_car-userdebug
19. aosp_flame-userdebug
20. aosp_sargo-userdebug
21. aosp_taimen-userdebug
22. aosp_walleye-userdebug
23. aosp_walleye_test-userdebug
24. aosp_x86-eng
25. aosp_x86_64-eng
26. arm_krait-eng
27. arm_v7_v8-eng
28. armv8-eng
29. armv8_kryo385-eng
30. beagle_x15-userdebug
31. beagle_x15_auto-userdebug
32. car_x86_64-userdebug
33. db845c-userdebug
34. fuchsia_arm64-eng
35. fuchsia_x86_64-eng
36. hikey-userdebug
37. hikey64_only-userdebug
38. hikey960-userdebug
39. hikey960_tv-userdebug
40. hikey_tv-userdebug
41. pixel3_mainline-userdebug
42. poplar-eng
43. poplar-user
44. poplar-userdebug
45. qemu_trusty_arm64-userdebug
46. silvermont-eng
47. uml-userdebug
48. yukawa-userdebug
49. yukawa_sei510-userdebug
Which would you like? [aosp_arm-eng] 25
============================================
PLATFORM_VERSION_CODENAME=S
PLATFORM_VERSION=S
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.19.104-microsoft-standard-x86_64-Ubuntu-20.04-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=AOSP.MASTER
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl device/generic/goldfish device/generic/goldfish-opengl
============================================
- 執(zhí)行編譯命令make -j8
andy@andy-PC:/mnt/d/07.workspace/aosp$ make -j8
23:30:00 ************************************************************
23:30:00 You are building on a machine with 12.4GB of RAM
23:30:00
23:30:00 The minimum required amount of free memory is around 16GB,
23:30:00 and even with that, some configurations may not work.
23:30:00
23:30:00 If you run into segfaults or other errors, try reducing your
23:30:00 -j value.
23:30:00 ************************************************************
============================================
PLATFORM_VERSION_CODENAME=S
PLATFORM_VERSION=S
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-4.19.104-microsoft-standard-x86_64-Ubuntu-20.04-LTS
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=AOSP.MASTER
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl device/generic/goldfish device/generic/goldfish-opengl
============================================
- 編譯成功的日志打印和截圖如下
說(shuō)明:編譯成功用時(shí) (06:08:37 (hh:mm:ss))艇拍,這是在多次編譯情況下成功的耗時(shí)狐蜕,若首次的話(經(jīng)過(guò)多次長(zhǎng)時(shí)間的編譯才成功,中間遇到了很多坑)淑倾,時(shí)間應(yīng)該會(huì)更長(zhǎng)馏鹤。。娇哆。
frameworks/base/services/usb/java/com/android/server/usb/UsbPortManager.java:50: info: Unresolved import: `android.hardware.usb.V1_2.PortStatus` [UnresolvedImport]
frameworks/base/services/usb/java/com/android/server/usb/UsbPortManager.java:51: info: Unresolved import: `android.hidl.manager.V1_0.IServiceManager` [UnresolvedImport]
frameworks/base/services/usb/java/com/android/server/usb/UsbPortManager.java:52: info: Unresolved import: `android.hidl.manager.V1_0.IServiceNotification` [UnresolvedImport]metalava detected access to files that are not explicitly specified. See /mnt/d/07.workspace/aosp/out/soong/.intermediates/frameworks/base/services/services-stubs.sources/android_common/services-stubs.sources-violations.txt for details.
[ 99% 2301/2319] Target Java: out/target/common/obj/APPS/Dialer_intermediates/classes-full-debug.jar
Note: Generating a Provider for com.android.dialer.glidephotomanager.impl.GlidePhotoManagerImpl. Prefer to run the dagger processor over that class instead.
Note: [1] Wrote GeneratedAppGlideModule with: []
[ 99% 2304/2319] R8: out/target/common/obj/APPS/Dialer_intermediates/dex/classes.dex
Stripped invalid locals information from 1 method.
In ./out/target/common/obj/APPS/Dialer_intermediates/classes.jar:android/support/v7/widget/Toolbar.class:
Methods with invalid locals information:
void android.support.v7.widget.Toolbar.onLayout(boolean, int, int, int, int)
Type information in locals-table is inconsistent. Cannot constrain type: INT for value: v419 by constraint OBJECT.
Some warnings are typically a sign of using an outdated Java toolchain. To fix, recompile the source with an updated toolchain.
[100% 2319/2319] Target vbmeta image: out/target/product/generic/vbmeta.img
#### build completed successfully (06:08:37 (hh:mm:ss)) ####
andy@andy-PC:/mnt/d/07.workspace/aosp$