平台
rk3288 + android 7.1
问题
使用make otapackage 编译失败, log 如下:
Running: e2fsck -f -n /tmp/unsparse_system-UwjZR9.img e2fsck 1.42.9 (28-Dec-2013) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information system: 1923/131072 files (0.0% non-contiguous), 148861/524288 blocks Traceback (most recent call last): File "./build/tools/releasetools/add_img_to_target_files", line 476, in <module> main(sys.argv[1:]) File "./build/tools/releasetools/add_img_to_target_files", line 470, in main AddImagesToTargetFiles(args[0]) File "./build/tools/releasetools/add_img_to_target_files", line 389, in AddImagesToTargetFiles boot_img=boot_image) File "./build/tools/releasetools/add_img_to_target_files", line 109, in AddSystem block_list=block_list) File "./build/tools/releasetools/add_img_to_target_files", line 118, in BuildSystem return CreateImage(input_dir, info_dict, "system", block_list=block_list) File "./build/tools/releasetools/add_img_to_target_files", line 214, in CreateImage img_out = os.path.join(os.environ["OUT"],"system.img") File "/usr/lib/python2.7/UserDict.py", line 40, in __getitem__ raise KeyError(key) KeyError: 'OUT' ninja: build stopped: subcommand failed. build/core/ninja.mk:148: recipe for target 'ninja_wrapper' failed make: *** [ninja_wrapper] Error 1 #### make failed to build some targets (02:39 (mm:ss)) ####
分析
请同事尝试编译, 他那边的代码是正常的, 无法确认根源.
在上面的LOG中 : os.path.join(os.environ[“OUT”],“system.img”)
没写过PY脚本, 假设性地查看了下 OUT 环境变量发现,
我的环境下, OUT是空的. 而同事的OUT目录指向的却是源码编译的OUT目录.
于是找了另外一台PC验证了下, 尝试给OUT赋上正确的值, 结果编译通过了, 那么问题根源找到了.
而后, 对比编译命令发现, 我缺少了执行lunch xxx命令.
惯性所致, 习惯了旧的SDK上, source 完 envsetup.sh 后, 自动lunch了
PS: 有个小插曲, 刚开始并不会报这个错误, 因为我先编译了5.1的代码, 而其中, OUT变量已经赋了值, 虽然不正确, 但不会导致编译失败