在日常的工作中,很多场景都需要分析人员编译Android系统源码,例如:
-
动态调试Android系统源码
-
将最新的Android官方系统源码刷入自己的Android设备
-
定制Android系统,大早专属的脱壳工具
-
编译Android内核并刷机,以绕过反调试Android官方支持在linux中编译系统源码。Docker的研发与使用,让Windows平台的用户也能不安装虚拟机而顺利地在Windows中编译Android系统源码。目前,在Windows和linux这两大系统平台上,都能够正常编译Android源码和刷机。
一、在Ubuntu中编译Android源码
Ubuntu是Android官方默认支持的Android系统源码编译系统,按照官方网站的环境配置说明进行配置后,就可以进行编译了。首先是安装JDK。编译不同版本的Android源码,就需要安装不同版本的JDK。这一点我们前面也讲过很多次,此处就不再赘述。然后,执行如下命令,安装下载和编译Android源码时需要使用的软件。
sudo apt-get install git-core gnupg flex bison gperf build-essential




curl https://storage.googleapis.com/git-repo-downloads/repo > usr/bin/repo

git config --global user.name "your name"
git config --global user.email "[email protected]"
接下来执行以下命令,下载和同步源码。
repo init -u https://android.googlesource.com/platform/mainfest -b android-7.1.1_r1
repo sync --force-sync --force-broken

export USE_CCACHE=1
export CCACHE_DIR=ccache
prebuilts/misc/linux-x86/ccache/ccache -M 50G
source build/envsetup.sh
lunch aosp_angler-userdebug
make clobber
make -j8
二、在Windows中编译Android源码
Docker支持的最低Windows版本是Windows7。该版本需要借助Docker Toolbox在VirtualBox虚拟机汇总的容器进行通信,效率相对较低。由于Windows 10原生系统支持Docker,则我们用Windows10来编译Android系统源码。
Docker 有专门的 Win10 专业版系统的安装包,需要开启Hyper-V。通过控制面板-程序-程序和功能,找到启用或关闭Windows功能,选中Hyper-V






wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6/
./configure -prefix=/usr/local -with-shared-without-debug
make
make install
来源:freebuf.com 2020-08-20 13:43:08 by: lsunmmer

评论