文章目录
准备工作
配置软件源
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
源码目录设置大小写敏感
PS C:\Windows\system32> fsutil.exe file setCaseSensitiveInfo E:\source enable
已启用目录 E:\source 的区分大小写属性。
PS C:\Windows\system32>
开启CCACHE提高编译速度
当你删掉out/target目录或者使用make clean清空输出重新编译源码的时候,编译时间通常都很漫长。其实这个问题很容易解决,Android官方为我们带来了解决方案–ccache编译器缓存。官方这么讲:You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do “make clean” often, or if you frequently switch between different build products.
您可以选择告诉构建使用ccache编译工具。Ccache充当编译器缓存,可用于加快重建速度。如果您经常“清理”或经常在不同的构建产品之间进行切换,则此方法非常有用。
- 设置ccache的大小,通常在50G~100G
vi ~/.bashrc
export USE_CACHE=1
export CCACHE_COMPILE=1 //可选,压缩导致性能下降,但是减小所占磁盘存储
export CCACHE_DIR=/mnt/d/codes/.ccache //设置ccache的缓存目录
- 启动ccache
./prebuilts/misc/linux-x86/ccache/ccache -M 50
- 查看ccache的状态
ccache -s
- 清除ccache的状态
ccache -c
编译出现的错误
ftruncate(fd_out, GetSize()): Invalid argument
出现这个错误的原因是将classes.jar 转换为 classes.jar.toc.jmp出现了问题,可以手动执行转换操作依然会报上面的错
解决方法:
然后重新生成 ijar
mmm build/tools/ijar
cannot execute binary file: Exec format error
出现问题的原因是不支持32位程序的执行
- 使bash支持32位程序运行
sudo apt update
sudo apt install qemu-user-static
- 设置 bitfmt
sudo update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
- 启动服务 注意:binfmt服务在每次启动bash控制台时都需要启动
service binfmt-support start
/lib/ld-linux.so.2: No such file or directory
执行vendor/mediatek/proprietary/bootable/bootloader/lk/dev/logo/tool/bmp_to_raw
的时候会报错
提示缺少库,我的解决方法在Ubuntu上拷贝了一个/lib/ld-linux.so.2
到WSL中
然后继续提示
error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
这里继续安装
apt-get install lib32z1*
/bin/bash: xmllint: command not found
sudo apt-file search xmllint
sudo apt-get install libxml2-utils
dex2oat did not finish after 2850 seconds
如果是boot.jar出现这个问题
在build\core\dex_preopt_libart_boot.mk文件中追加-j1,使用单线程编译odex
如果是某个app出现这个问题
在build\core\dex_preopt_libart.mk文件中追加-j1,使用单线程编译odex
其他问题
类似的都是安装包问题,直接apt-get install 安装就好