Android实战技巧之四十:Android5.1.1源代码编译与烧写

购买Nexus手机的朋友大多是为了自己修改系统玩,再加上其较高的性价比,在开发者中还是广受欢迎的。我的5太子被我升级到了6.0预览版,玩的正嗨,舍不得换回到5.1时代了。不过鉴于距6.0源码发布还有段日子,5.1的源码编译与烧写仍是主流,下面就记录了整个过程(持续了很长时间,,我们要有耐心)。

搭建开发环境

系统推荐Ubuntu 14.04 1.openjdk is needed

$ sudo apt-get update$ sudo apt

set it the default java version

$ sudo update-alternatives –config java$ sudo update-alternatives –config javac

2.required package

sudo apt-get install bison g++-multilib git gperf libxml2-utils make python-networkx zlib1g-dev:i386 zip

遇到问题:

$ sudo apt-get install bison g++-multilib git gperf libxml2-utils make python-networkx zlib1g-dev:i386 zip[sudo] password for linc: Reading package lists… DoneBuilding dependency treeReading state information… Donemake is already the newest version.zip is already the newest version.git is already the newest version.git set to manually installed.libxml2-utils is already the newest version.libxml2-utils set to manually installed.Some packages could not be installed. This may mean that you haverequested an impossible situation or if you are using the unstabledistribution that some required packages have not yet been createdor been moved out of Incoming.The following information may help to resolve the situation:The following packages have unmet dependencies: g++-multilib : Depends: gcc-multilib (>= going to be installedE: Unable to correct problems, you have held broken packages

按照如下步骤即可:

$ sudo apt-get install g++-multilib$ sudo apt-get install bison git gperf libxml2-utils make python-networkx zlib1g-dev:i386 zipgcc为必须$ sudo apt-get install gcc$ gcc -vThread model: posixgcc version ubuntu1~14.04) repo$ mkdir ~/binATH$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo$ chmod a+x ~/bin/repo

check sh1 sum:

$ sha1sum repo b8bd1804f432ecf1bab730949c82b93b0fc5fede repo

For version 1.21, the SHA-1 checksum for repo is b8bd1804f432ecf1bab730949c82b93b0fc5fede

repo init

针对Nexus5的5.1.1的初始化如下:

LMY48I android-5.1.1_r9 Lollipop Nexus 4, Nexus 5, Nexus 6, Nexus 7 (flo), Nexus 9 (volantis/volantisg), Nexus 10$ repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.1_r9Your identity is: linc config-nameTesting colorized output (for ‘repo diff’, ‘repo status’): black redgreen yellow bluemagenta cyanwhite bolddimulreverse repo has been initialized in /home/linc/source-android/android-sourcerepo sync$ repo sync

一个晚上两个白天,终于下载完成,代码达34G.

Setting up ccache

Put the following in your .bashrc (or equivalent):

export USE_CCACHE=1

run the command:

prebuilts/misc/linux-x86/ccache/ccache -M 50GBuilding the System

1.Set up environment

$ source build/envsetup.sh

or

$ . build/envsetup.sh

2.Choose a Target

$ lunch You’re building on LinuxLunch menu… pick a combo:1. aosp_arm-eng2. aosp_arm64-eng3. aosp_mips-eng4. aosp_mips64-eng5. aosp_x86-eng6. aosp_x86_64-eng7. aosp_manta-userdebug8. aosp_flo-userdebug9. aosp_deb-userdebug10. full_fugu-userdebug11. aosp_fugu-userdebug12. aosp_tilapia-userdebug13. aosp_grouper-userdebug14. aosp_mako-userdebug15. aosp_hammerhead-userdebug16. aosp_flounder-userdebug17. aosp_shamu-userdebug18. mini_emulator_x86-userdebug19. mini_emulator_arm64-userdebug20. mini_emulator_x86_64-userdebug21. mini_emulator_mips-userdebug22. m_e_arm-userdebugWhich would you like? [aosp_arm-eng]

Nexus5就选择了15,如果只是用于模拟器就选择1好了。 3.build

make -j4

如果遇到等待其他任务完成的错误,是多线程冲突,就直接make好了。 4.error 1)

No private recovery resources for TARGET_DEVICE hammerheadhost C++: bcc <= frameworks/compile/libbcc/tools/bcc/Main.cppclang++: error: unable to execute command: Executable “as” doesn’t exist!clang++: error: assembler command failed with exit code 1 (use -v to see invocation)make: *** [out/host/linux-x86/obj32/EXECUTABLES/bcc_intermediates/Main.o] Error 1

try make clean.这是没有安装gcc的后果。

build successfully#### (05####人格的完善是本,财富的确立是末。

Android实战技巧之四十:Android5.1.1源代码编译与烧写

相关文章:

你感兴趣的文章:

标签云: