目的
编译Android sdk。注意不是编译Android img,如果想了解两者区别,可以看上一篇:https://blog.csdn.net/CSDN1013/article/details/106213690
问题
1. 编译步骤:
$ . build/envsetup.sh
$ lunch
$ make -j8 sdk
2. 错误提示:
development/build/sdk-linux-x86.atree:36: couldn't locate source file: lib64/libaapt2_jni.so
development/build/sdk.atree:53: couldn't locate source file: bin/dmtracedump
development/build/sdk.atree:54: couldn't locate source file: bin/etc1tool
development/build/sdk.atree:84: couldn't locate source file: bin/split-select
development/build/sdk.atree:89: couldn't locate source file: bin/bcc_compat
development/build/sdk.atree:129: couldn't locate source file: bin/apksigner
development/build/sdk.atree:130: couldn't locate source file: framework/apksigner.jar
development/build/sdk.atree:133: couldn't locate source file: bin/dx
development/build/sdk.atree:134: couldn't locate source file: framework/dx.jar
development/build/sdk.atree:209: couldn't locate source file: framework/layoutlib-legacy.jar
development/build/sdk.atree:235: couldn't locate source file: system-qemu.img
development/build/sdk.atree:236: couldn't locate source file: vendor-qemu.img
development/build/sdk.atree:238: couldn't locate source file: data/misc
system/app/EmulatorSmokeTests/EmulatorSmokeTests.apk
ninja: build stopped: subcommand failed.
10:51:16 ninja failed with: exit status 1
#### failed to build some targets (04:38:30 (hh:mm:ss)) ####
3. 解决方法:
整体思路:出现上述错误后,分别编译这些系统未能找到工具。然后,再次编译sdk。
解决步骤:
#第一,在出现错误提示的终端里继续编译
#如果在另一个终端里编译,则需要先设置Android编译环境
#Build missing tools
$ make dmtracedump
[100% 12/12] Install: out/host/linux-x86/bin/dmtracedump
#### build completed successfully (03:20 (mm:ss)) ####
$ make etc1tool
[100% 52/52] Install: out/host/windows-x86/bin/etc1tool.exe
#### build completed successfully (18 seconds) ####
$ make split-select
[100% 135/135] Install: out/host/windows-x86/bin/split-select.exe
#### build completed successfully (40 seconds) ####
$ make bcc_compat
[100% 1164/1164] Install: out/host/windows-x86/bin/bcc_compat.exe
#### build completed successfully (15:52 (mm:ss)) ####
$ make apksigner
[100% 8/8] Install: out/host/linux-x86/bin/apksigner
#### build completed successfully (04:05 (mm:ss)) ####
$ make dx
[100% 9/9] Install: out/host/linux-x86/bin/dx
#### build completed successfully (15 seconds) ####
$ make libaapt2_jni
[100% 531/531] build out/host/windows-x86/obj64/SHARED_LIBRARIES/libaapt2_jni_intermediates/libaapt2_jni.dll.toc
#### build completed successfully (03:20 (mm:ss)) ####
$ make layoutlib-legacy
[100% 9/9] Install: out/host/linux-x86/framework/layoutlib-legacy.jar
#### build completed successfully (9 seconds) ####
#第二,注释development/build/sdk.atree文件
----data/misc system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/data/misc
----system-qemu.img system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/system.img
----vendor-qemu.img system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/vendor.img
++++#data/misc system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/data/misc
++++#system-qemu.img system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/system.img
++++#vendor-qemu.img system-images/${PLATFORM_NAME}/${TARGET_CPU_ABI}/vendor.img
$make -j8 sdk