基于Ubuntu 14.04 LTS编译Android4.4.2源代码
转载自:雨水:http://blog.csdn.net/gobitan/article/details/24367439
- $sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dri:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 dpkg-dev
- $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
$sudo apt-get install git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dri:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 dpkg-dev $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
- # adb protocol on passion (Nexus One)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>"
- # fastboot protocol on passion (Nexus One)
- SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>"
- # adb protocol on crespo/crespo4g (Nexus S)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>"
- # fastboot protocol on crespo/crespo4g (Nexus S)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>"
- # adb protocol on stingray/wingray (Xoom)
- SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="<username>"
- # fastboot protocol on stingray/wingray (Xoom)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="<username>"
- # adb protocol on maguro/toro (Galaxy Nexus)
- SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>"
- # fastboot protocol on maguro/toro (Galaxy Nexus)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>"
- # adb protocol on panda (PandaBoard)
- SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="<username>"
- # adb protocol on panda (PandaBoard ES)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0600", OWNER="<username>"
- # fastboot protocol on panda (PandaBoard)
- SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="<username>"
- # usbboot protocol on panda (PandaBoard)
- SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER="<username>"
- # usbboot protocol on panda (PandaBoard ES)
- SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="<username>"
- # adb protocol on grouper/tilapia (Nexus 7)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER="<username>"
- # fastboot protocol on grouper/tilapia (Nexus 7)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER="<username>"
- # adb protocol on manta (Nexus 10)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0600", OWNER="<username>"
- # fastboot protocol on manta (Nexus 10)
- SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0600", OWNER="<username>"
# adb protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="<username>" # fastboot protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER="<username>" # adb protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER="<username>" # fastboot protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER="<username>" # adb protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER="<username>" # fastboot protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER="<username>" # adb protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER="<username>" # fastboot protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER="<username>" # adb protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER="<username>" # adb protocol on panda (PandaBoard ES) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0600", OWNER="<username>" # fastboot protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER="<username>" # usbboot protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER="<username>" # usbboot protocol on panda (PandaBoard ES) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER="<username>" # adb protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER="<username>" # fastboot protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER="<username>" # adb protocol on manta (Nexus 10) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0600", OWNER="<username>" # fastboot protocol on manta (Nexus 10) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0600", OWNER="<username>"
然后执行如下命令,将上述文件中的username替换为你的用户名。
- $sudo sed -i ‘s/username/dennis/g‘ /etc/udev/rules.d/51-android.rules
$sudo sed -i ‘s/username/dennis/g‘ /etc/udev/rules.d/51-android.rules4. 配置ccache
- $sudo apt-get install ccache
- $source ~/.bashrc
$sudo apt-get install ccache $source ~/.bashrc
- $ mkdir ~/bin
- $ PATH=~/bin:$PATH
$ mkdir ~/bin $ PATH=~/bin:$PATH(2) 下载repo工具
- curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo
curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo
- $ chmod a+x ~/bin/repo
$ chmod a+x ~/bin/repo
- $mkdir aosp
- $cd aosp
$mkdir aosp $cd aosp(2) 初始化repo
- 74.125.71.82 www.googlesource.com
- 74.125.31.82 android.googlesource.com
- 203.208.46.172 cache.pack.google.com
- 59.24.3.173 cache.pack.google.com
74.125.71.82 www.googlesource.com 74.125.31.82 android.googlesource.com 203.208.46.172 cache.pack.google.com 59.24.3.173 cache.pack.google.com至于为什么要出现网络错误,你懂的!
- $repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.2_r2
$repo init -u https://android.googlesource.com/platform/manifest -b android-4.4.2_r2
- git config --global user.email "[email protected]"
- git config --global user.name "Your Name"
git config --global user.email "[email protected]" git config --global user.name "Your Name"
- $repo sync
$repo sync
- $ cd aosp
- $ prebuilts/misc/linux-x86/ccache/ccache -M 50G
$ cd aosp $ prebuilts/misc/linux-x86/ccache/ccache -M 50G2. 设置输出目录
- dennis@dubuntu1404:~/devenv/aosp$ . build/envsetup.sh
- including device/samsung/manta/vendorsetup.sh
- including device/generic/mips/vendorsetup.sh
- including device/generic/armv7-a-neon/vendorsetup.sh
- including device/generic/x86/vendorsetup.sh
- including device/lge/mako/vendorsetup.sh
- including device/lge/hammerhead/vendorsetup.sh
- including device/asus/tilapia/vendorsetup.sh
- including device/asus/deb/vendorsetup.sh
- including device/asus/grouper/vendorsetup.sh
- including device/asus/flo/vendorsetup.sh
- including sdk/bash_completion/adb.bash
- dennis@dubuntu1404:~/devenv/aosp$
dennis@dubuntu1404:~/devenv/aosp$ . build/envsetup.sh including device/samsung/manta/vendorsetup.sh including device/generic/mips/vendorsetup.sh including device/generic/armv7-a-neon/vendorsetup.sh including device/generic/x86/vendorsetup.sh including device/lge/mako/vendorsetup.sh including device/lge/hammerhead/vendorsetup.sh including device/asus/tilapia/vendorsetup.sh including device/asus/deb/vendorsetup.sh including device/asus/grouper/vendorsetup.sh including device/asus/flo/vendorsetup.sh including sdk/bash_completion/adb.bash dennis@dubuntu1404:~/devenv/aosp$
- dennis@dubuntu1404:~/devenv/aosp$ lunch
- You‘re building on Linux
- Lunch menu... pick a combo:
- 1. aosp_arm-eng
- 2. aosp_x86-eng
- 3. aosp_mips-eng
- 4. vbox_x86-eng
- 5. aosp_manta-userdebug
- 6. mini_mips-userdebug
- 7. mini_armv7a_neon-userdebug
- 8. mini_x86-userdebug
- 9. aosp_mako-userdebug
- 10. aosp_hammerhead-userdebug
- 11. aosp_tilapia-userdebug
- 12. aosp_deb-userdebug
- 13. aosp_grouper-userdebug
- 14. aosp_flo-userdebug
- Which would you like? [aosp_arm-eng] 9
- ============================================
- PLATFORM_VERSION_CODENAME=REL
- PLATFORM_VERSION=4.4.2
- TARGET_PRODUCT=aosp_mako
- TARGET_BUILD_VARIANT=userdebug
- TARGET_BUILD_TYPE=release
- TARGET_BUILD_APPS=
- TARGET_ARCH=arm
- TARGET_ARCH_VARIANT=armv7-a-neon
- TARGET_CPU_VARIANT=krait
- HOST_ARCH=x86
- HOST_OS=linux
- HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty
- HOST_BUILD_TYPE=release
- BUILD_ID=KVT49L
- OUT_DIR=out
- ============================================
- dennis@dubuntu1404:~/devenv/aosp$ make -j4
dennis@dubuntu1404:~/devenv/aosp$ lunch You‘re building on Linux Lunch menu... pick a combo: 1. aosp_arm-eng 2. aosp_x86-eng 3. aosp_mips-eng 4. vbox_x86-eng 5. aosp_manta-userdebug 6. mini_mips-userdebug 7. mini_armv7a_neon-userdebug 8. mini_x86-userdebug 9. aosp_mako-userdebug 10. aosp_hammerhead-userdebug 11. aosp_tilapia-userdebug 12. aosp_deb-userdebug 13. aosp_grouper-userdebug 14. aosp_flo-userdebug Which would you like? [aosp_arm-eng] 9 ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=4.4.2 TARGET_PRODUCT=aosp_mako TARGET_BUILD_VARIANT=userdebug TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a-neon TARGET_CPU_VARIANT=krait HOST_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=KVT49L OUT_DIR=out ============================================ dennis@dubuntu1404:~/devenv/aosp$ make -j4注:j4中的数字跟你的CPU个数和核数有关,详细参见参考资料[3].
- $ sudo apt-get install android-tools-fastboot
$ sudo apt-get install android-tools-fastboot
- export ANDROID_PRODUCT_OUT=/home/dennis/devenv/aosp/out/target/product/mako
export ANDROID_PRODUCT_OUT=/home/dennis/devenv/aosp/out/target/product/mako
- $ adb reboot bootloader
$ adb reboot bootloader
- dennis@dubuntu1404:~/devenv/aosp/out$ fastboot flashall -w
- --------------------------------------------
- Bootloader Version...: PRIMEMD04
- Baseband Version.....: I9250XXLJ1
- Serial Number........: 0146A0D00600900B
- --------------------------------------------
- checking product...
- FAILED
- Device product is ‘tuna‘.
- Update requires ‘mako‘.
- finished. total time: 0.035s
dennis@dubuntu1404:~/devenv/aosp/out$ fastboot flashall -w -------------------------------------------- Bootloader Version...: PRIMEMD04 Baseband Version.....: I9250XXLJ1 Serial Number........: 0146A0D00600900B -------------------------------------------- checking product... FAILED Device product is ‘tuna‘. Update requires ‘mako‘. finished. total time: 0.035s
- $ cd aosp
- dennis@dubuntu1404:~/devenv/aosp$ . build/envsetup.sh
- including device/samsung/manta/vendorsetup.sh
- including device/generic/mips/vendorsetup.sh
- including device/generic/armv7-a-neon/vendorsetup.sh
- including device/generic/x86/vendorsetup.sh
- including device/lge/mako/vendorsetup.sh
- including device/lge/hammerhead/vendorsetup.sh
- including device/asus/tilapia/vendorsetup.sh
- including device/asus/deb/vendorsetup.sh
- including device/asus/grouper/vendorsetup.sh
- including device/asus/flo/vendorsetup.sh
- including sdk/bash_completion/adb.bash
- dennis@dubuntu1404:~/devenv/aosp$ lunch aosp_arm-eng
- ============================================
- PLATFORM_VERSION_CODENAME=REL
- PLATFORM_VERSION=4.4.2
- TARGET_PRODUCT=aosp_arm
- TARGET_BUILD_VARIANT=eng
- TARGET_BUILD_TYPE=release
- TARGET_BUILD_APPS=
- TARGET_ARCH=arm
- TARGET_ARCH_VARIANT=armv7-a
- TARGET_CPU_VARIANT=generic
- HOST_ARCH=x86
- HOST_OS=linux
- HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty
- HOST_BUILD_TYPE=release
- BUILD_ID=KVT49L
- OUT_DIR=out
- ============================================
- dennis@dubuntu1404:~/devenv/aosp$ make -j4
- ============================================
- PLATFORM_VERSION_CODENAME=REL
- PLATFORM_VERSION=4.4.2
- TARGET_PRODUCT=aosp_arm
- TARGET_BUILD_VARIANT=eng
- TARGET_BUILD_TYPE=release
- TARGET_BUILD_APPS=
- TARGET_ARCH=arm
- TARGET_ARCH_VARIANT=armv7-a
- TARGET_CPU_VARIANT=generic
- HOST_ARCH=x86
- HOST_OS=linux
- HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty
- HOST_BUILD_TYPE=release
- BUILD_ID=KVT49L
- OUT_DIR=out
- ============================================
- including ./abi/cpp/Android.mk ...
- including ./art/Android.mk ...
- ....中间过程省略
- Install system fs image: out/target/product/generic/system.img
- out/target/product/generic/system.img+ maxsize=588791808 blocksize=2112 total=576716800 reserve=5947392
$ cd aosp dennis@dubuntu1404:~/devenv/aosp$ . build/envsetup.sh including device/samsung/manta/vendorsetup.sh including device/generic/mips/vendorsetup.sh including device/generic/armv7-a-neon/vendorsetup.sh including device/generic/x86/vendorsetup.sh including device/lge/mako/vendorsetup.sh including device/lge/hammerhead/vendorsetup.sh including device/asus/tilapia/vendorsetup.sh including device/asus/deb/vendorsetup.sh including device/asus/grouper/vendorsetup.sh including device/asus/flo/vendorsetup.sh including sdk/bash_completion/adb.bash dennis@dubuntu1404:~/devenv/aosp$ lunch aosp_arm-eng ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=4.4.2 TARGET_PRODUCT=aosp_arm TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a TARGET_CPU_VARIANT=generic HOST_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=KVT49L OUT_DIR=out ============================================ dennis@dubuntu1404:~/devenv/aosp$ make -j4 ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=4.4.2 TARGET_PRODUCT=aosp_arm TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a TARGET_CPU_VARIANT=generic HOST_ARCH=x86 HOST_OS=linux HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=KVT49L OUT_DIR=out ============================================ including ./abi/cpp/Android.mk ... including ./art/Android.mk ... ....中间过程省略 Install system fs image: out/target/product/generic/system.img out/target/product/generic/system.img+ maxsize=588791808 blocksize=2112 total=576716800 reserve=5947392
- $. build/envsetup.sh
- $lunch aosp_arm-eng
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。