创建一个映像用来下载android源码
1, $ hdiutil create -type SPARSE -fs ‘Case-sensitive Journaled HFS+’ -size 40g ~/android.sparseimage
2, $ hdiutil attach ~/android.sparseimage -mountpoint /Volumes/android
3, $ mkdir ~/bin
4, $ PATH=~/bin:$PATH
5, $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
6, $ chmod a+x ~/bin/repo
7, $ cd /Volumes/android/
8, $ mkdir WORKING_DIRECTORY
9, $ CD WORKING_DIRECTORY/
10, $ repo init -u https://android.googlesource.com/platform/manifest -b android-4.2.2_r1
11, $repo sync
设置必要的编译环境初始化编译环境:
1, $source build/envsetup.sh
2, 选择编译目标 $lunch full-eng
开始编译代码
$make -j8
开始时间 2013-03-28 19:17
编译到了 40分钟左右的时候出现了错误 No space left on device,看错误3解决方法。
之后接着编译 make 这次没有是用 -j,因为心疼电脑,嘿嘿 ,大概半小时编译完成。
nstalled file list: out/target/product/generic/installed-files.txt
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
Running: mkyaffs2image -f out/target/product/generic/system out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
Install system fs image: out/target/product/generic/system.img
编译完成后运行:emulator -kernel ./prebuilts/qemu-kernel/arm/kernel-qemu -sysdir ./out/target/product/generic -system system.img -data userdata.img -ramdisk ramdisk.img
出现错误 qemu: could not load initrd ‘ramdisk.img’,看错误4解决方法
直接运行: emulator -kernel ./prebuilts/qemu-kernel/arm/kernel-qemu-armv7 -sysdir ./out/target/product/generic/ -system system.img -data userdata.img
最终结果图 :
错误 1
在android4.0源码中,mm编译apk时出现下面的错误:
make: *** No rule to make target `out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/javalib.jar', needed by `out/target/common/obj/APPS/NativeTimer_intermediates/classes-full-debug.jar'. Stop.
解决方法: 在源码根目录执行: make clobber make -j8
这个错误的好像是由于在make一个任务时,并没有结束,这时在进行make就会报 make clobber的功能是把上一次make命令生成的文件或目录清除掉,效果比make clean更严格。 这样编译完成后,在编译apk就可以了。
错误2
povolmatoMacBook-Pro:untitled povol$ source build/envsetup.sh
including device/asus/grouper/vendorsetup.sh
including device/asus/tilapia/vendorsetup.sh
including device/generic/armv7-a-neon/vendorsetup.sh
including device/generic/armv7-a/vendorsetup.sh
including device/generic/mips/vendorsetup.sh
including device/generic/x86/vendorsetup.sh
including device/lge/mako/vendorsetup.sh
including device/samsung/maguro/vendorsetup.sh
including device/samsung/manta/vendorsetup.sh
including device/samsung/toro/vendorsetup.sh
including device/samsung/toroplus/vendorsetup.sh
including device/ti/panda/vendorsetup.sh
including sdk/bash_completion/adb.bash
povolmatoMacBook-Pro:untitled povol$ lunch full-eng
build/core/combo/HOST_darwin-x86.mk:62: *****************************************************
build/core/combo/HOST_darwin-x86.mk:63: * Cannot find SDK 10.6 at /Applications/Xcode.app/
Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
build/core/combo/HOST_darwin-x86.mk:65: * If you wish to build using higher version of SDK,
build/core/combo/HOST_darwin-x86.mk:66: * try setting BUILD_MAC_SDK_EXPERIMENTAL=1 before
build/core/combo/HOST_darwin-x86.mk:67: * rerunning this command
build/core/combo/HOST_darwin-x86.mk:69: *****************************************************
build/core/combo/HOST_darwin-x86.mk:70: *** Stop.. Stop.
** Don't have a product spec for: 'full'
** Do you have the right repo manifest?
//**//找不到mac os x sdk 10.6 执行
povolmatoMacBook-Pro:untitled povol$ export BUILD_MAC_SDK_EXPERIMENTAL=1
povolmatoMacBook-Pro:untitled povol$ lunch full-eng
一些初始化信息
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.2.2
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=darwin
HOST_OS_EXTRA=Darwin-12.3.0-x86_64-i386-64bit
HOST_BUILD_TYPE=release
BUILD_ID=JDQ39
OUT_DIR=out
============================================
povolmatoMacBook-Pro:untitled povol$
========================================================
错误3
/Volumes/untitled/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld: fatal error: out/target/product/generic/obj/SHARED_LIBRARIES/libmock_ril_intermediates/LINKED/libmock_ril.so: No space left on device
collect2: ld returned 1 exit status
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libmock_ril_intermediates/LINKED/libmock_ril.so] Error 1
make: *** Waiting for unfinished jobs....
/Volumes/untitled/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld: warning: hidden symbol 'mkstemp' in out/target/product/generic/obj/SHARED_LIBRARIES/libchromium_net_intermediates/base/file_util_android.o is referenced by DSO out/target/product/generic/obj/lib/libcutils.so
/Volumes/untitled/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld: fatal error: out/target/product/generic/obj/SHARED_LIBRARIES/libchromium_net_intermediates/LINKED/libchromium_net.so: No space left on device
collect2: ld returned 1 exit status
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libchromium_net_intermediates/LINKED/libchromium_net.so] Error 1
/Volumes/untitled/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6/bin/../lib/gcc/arm-linux-androideabi/4.6.x-google/../../../../arm-linux-androideabi/bin/ld: fatal error: out/target/product/generic/obj/SHARED_LIBRARIES/libbcc_intermediates/LINKED/libbcc.so: No space left on device
collect2: ld returned 1 exit status
make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libbcc_intermediates/LINKED/libbcc.so] Error 1
解决:
执行 df -li 查看 iused 我的在untitled 显示100%
povolmatoMacBook-Pro:untitled povol$ df -li
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk0s2 777343744 450761888 326069856 59% 56409234 40758732 58% /
/dev/disk0s4 197748728 82422896 115325832 42% 183830 57683118 0% /Volumes/BOOTCAMP
/dev/disk1 8388608 1611096 6777512 20% 201385 847189 19% /Volumes/RamDisk
/dev/disk3s2 83214256 83193528 20728 100% 10399189 2591 100% /Volumes/untitled
所以提示 No space left on device
重新启动了mac之后
povolmatoMacBook-Pro:android povol$ df -li
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk0s2 777343744 482859288 293972456 63% 60421409 36746557 62% /
/dev/disk0s4 197748728 82422896 115325832 42% 183830 57683118 0% /Volumes/BOOTCAMP
/dev/disk1 8388608 73632 8314976 1% 9202 1039372 1% /Volumes/RamDisk
/dev/disk3s2 83214256 50383960 32830296 61% 6297993 4103787 61% /Volumes/untitled
这次显示/Volumes/untitled iused 为61% 接着运行 make 编译成功 。
错误 4
qemu: could not load initrd ‘ramdisk.img’,
直接参数-ramdisk ramdisk.img去掉,结果模拟器跑起来了,是运行出窗口后,就是黑屏。
换下kernel,用./prebuilts/qemu-kernel/arm/kernel-qemu-armv7,之后运行成功 。