Ubuntu 11.04 32位编译Android 4.0.3


这里只是记录一些日志,难免有些错误,欢迎批评指正。

环境的建立:http://source.Android.com/source/initializing.html
源码下载参考:http://source.android.com/source/downloading.html
这里我下载4.0.3 的源码:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.3_r1
下载的速度看个人的网络,这里我下了一天一夜。下载好之后就可以直接make -j4编译了,编译的时候用个大概3个小时,如果按照以上两个连接编译的话,除了内存不够之外的应该没有什么问题,这里我遇到的是就是内存不够。
我机子是VMware + Ubuntu 11.04  2G内存 2G swap,后面编译的话会遇到类似如下错误:
Install: out/host/linux-x86/framework/dx.jar
Copy: dx (out/host/linux-x86/obj/EXECUTABLES/dx_intermediates/dx)
Install: out/host/linux-x86/bin/dx
target Dex: core
make: *** [out/target/common/obj/JAVA_LIBRARIES/core_intermediates/noproguard.classes-with-local.dex] 已杀死
主要原因是内存不够,解决办法可以是增加虚拟机的内存,或者是增加swap的大小。
以下是增加swap文件方法
1.创建一个 Swap 文件。
mkdir swap
cd swap
sudo dd if=/dev/zero of=swapfile bs=1024 count=100000

出现下列提示,上面命令中的 count 即代表swap文件大小。

记录了 100000+0 的读入
记录了 100000+0 的写出
102400000 字节 (102 MB) 已复制,0.74704 秒,137 MB/秒

把生成的文件转换成 Swap 文件
sudo mkswap swapfile

Setting up swapspace version 1, size = 102395 kB
no label, UUID=09fde987-5567-498a-a60b-477e302a988b

2.激活 Swap 文件。
sudo swapon swapfile

编译好之后设置环境变量 最后用emulator 运行

www.bkjia.com @bkjia:~/android-4.0.3$ export PATH=$PATH:~/android-4.0.3/out/host/linux-x86/bin
www.bkjia.com @bkjia:~/android-4.0.3$ export ANDROID_PRODUCT_OUT=~/android-4.0.3/out/target/product/generic
www.bkjia.com @bkjia:~/android-4.0.3$ emulator

可以使用emulator -help 查看 命令的用法,例如

emulator -verbose 可以查看运行过程。

  1. www.bkjia.com @bkjia-station:~/android-4.0.3$ emulator -verbose  
  2. emulator: found Android build root: /home/luo/android-4.0.3  
  3. emulator: found Android build out:  /home/luo/android-4.0.3/out/target/product/generic  
  4. emulator: Found target ABI=armeabi-v7a, architecture=arm  
  5. emulator: Found target API level: 15  
  6. emulator: using core hw config path: /home/luo/android-4.0.3/out/target/product/generic/hardware-qemu.ini  
  7. emulator: found skin-specific hardware.ini: /home/luo/android-4.0.3/development/tools/emulator/skins/HVGA/hardware.ini  
  8. emulator: autoconfig: -skin HVGA  
  9. emulator: autoconfig: -skindir /home/luo/android-4.0.3/development/tools/emulator/skins  
  10. emulator: writing default keyset file to /home/luo/.android/default.keyset  
  11. emulator: trying to load skin file '/home/luo/android-4.0.3/development/tools/emulator/skins/HVGA/layout'  
  12. emulator: skin network speed: 'full'  
  13. emulator: skin network delay: 'none'  
  14. emulator: Found target ABI=armeabi-v7a  
  15. emulator: autoconfig: -kernel /home/luo/android-4.0.3/prebuilt/android-arm/kernel/kernel-qemu-armv7  
  16. emulator: autoconfig: -ramdisk /home/luo/android-4.0.3/out/target/product/generic/ramdisk.img  
  17. emulator: autoconfig: -sysdir /home/luo/android-4.0.3/out/target/product/generic  
  18. emulator: Using initial system image: /home/luo/android-4.0.3/out/target/product/generic/system.img  
  19. emulator: WARNING: system partition size adjusted to match image file (166 MB > 66 MB)  
  20.   
  21.   
  22. emulator: autoconfig: -data /home/luo/android-4.0.3/out/target/product/generic/userdata-qemu.img  
  23. emulator: autoconfig: -initdata /home/luo/android-4.0.3/out/target/product/generic/userdata.img  
  24. emulator: Physical RAM size: 512MB  
  25.   
  26.   
  27. emulator: Auto-config: -qemu -cpu cortex-a8  
  28. Content of hardware configuration file:  
  29.   hw.cpu.arch = arm  
  30.   hw.cpu.model = cortex-a8  
  31.   hw.ramSize = 512  
  32.   hw.touchScreen = yes  
  33.   hw.mainKeys = yes  
  34.   hw.trackBall = yes  
  35.   hw.keyboard = yes  
  36.   hw.keyboard.lid = no  
  37.   hw.keyboard.charmap = qwerty2  
  38.   hw.dPad = yes  
  39.   hw.gsmModem = yes  
  40.   hw.camera = no  
  41.   hw.camera.maxHorizontalPixels = 640  
  42.   hw.camera.maxVerticalPixels = 480  
  43.   hw.gps = yes  
  44.   hw.battery = yes  
  45.   hw.accelerometer = yes  
  46.   hw.audioInput = yes  
  47.   hw.audioOutput = yes  
  48.   hw.sdCard = yes  
  49.   hw.sdCard.path =   
  50.   disk.cachePartition = yes  
  51.   disk.cachePartition.path =   
  52.   disk.cachePartition.size = 66m  
  53.   hw.lcd.width = 320  
  54.   hw.lcd.height = 480  
  55.   hw.lcd.depth = 16  
  56.   hw.lcd.density = 160  
  57.   hw.lcd.backlight = yes  
  58.   hw.gpu.enabled = no  
  59.   hw.fakeCamera = back  
  60.   hw.webcam.count = 6  
  61.   hw.webcam.0.name = webcam0  
  62.   hw.webcam.1.name = webcam1  
  63.   hw.webcam.2.name = webcam2  
  64.   hw.webcam.3.name = webcam3  
  65.   hw.webcam.4.name = webcam4  
  66.   hw.webcam.5.name = webcam5  
  67.   hw.webcam.0.direction = front  
  68.   hw.webcam.1.direction = back  
  69.   hw.webcam.2.direction = front  
  70.   hw.webcam.3.direction = front  
  71.   hw.webcam.4.direction = front  
  72.   hw.webcam.5.direction = front  
  73.   vm.heapSize = 48  
  74.   hw.sensors.proximity = yes  
  75.   kernel.path = /home/luo/android-4.0.3/prebuilt/android-arm/kernel/kernel-qemu-armv7  
  76.   kernel.parameters =  android.checkjni=1  
  77.   disk.ramdisk.path = /home/luo/android-4.0.3/out/target/product/generic/ramdisk.img  
  78.   disk.systemPartition.initPath = /home/luo/android-4.0.3/out/target/product/generic/system.img  
  79.   disk.systemPartition.size = 166m  
  80.   disk.dataPartition.path = /home/luo/android-4.0.3/out/target/product/generic/userdata-qemu.img  
  81.   disk.dataPartition.size = 66m  
  82.   disk.snapStorage.path =   
  83.   avd.name = <build>  
  84. .  
  85. QEMU options list:  
  86. emulator: argv[00] = "/home/luo/android-4.0.3/out/host/linux-x86/bin/emulator-arm"  
  87. emulator: argv[01] = "-android-hw"  
  88. emulator: argv[02] = "/tmp/android-luo/emulator-afcKDX"  
  89. Concatenated QEMU options:  
  90.  /home/luo/android-4.0.3/out/host/linux-x86/bin/emulator-arm -android-hw /tmp/android-luo/emulator-afcKDX  
  91. emulator: registered 'boot-properties' qemud service  
  92. emulator: nand_add_dev: system,size=0xa600000,initfile=/home/luo/android-4.0.3/out/target/product/generic/system.img  
  93. emulator: mapping 'system' NAND image to /tmp/android-luo/emulator-eyG1eN  
  94. emulator: rounding devsize up to a full eraseunit, now a608000  
  95.   
  96.   
  97. WARNING: Data partition already in use. Changes will not persist!  
  98. emulator: nand_add_dev: userdata,size=0x4200000  
  99. emulator: mapping 'userdata' NAND image to /tmp/android-luo/emulator-RO2LHH  
  100. emulator: registered 'boot-properties' qemud service  
  101. emulator: Adding boot property: 'dalvik.vm.heapsize' = '48m'  
  102. emulator: Adding boot property: 'qemu.sf.lcd_density' = '160'  
  103. emulator: Adding boot property: 'qemu.hw.mainkeys' = '1'  
  104. emulator: Adding boot property: 'qemu.sf.fake_camera' = 'back'  
  105. emulator: nand_add_dev: cache,size=0x4200000  
  106. emulator: mapping 'cache' NAND image to /tmp/android-luo/emulator-wX6JvG  
  107. emulator: Kernel parameters: qemu.gles=0 qemu=1 console=ttyS0 android.qemud=ttyS1 android.checkjni=1 ndns=1  
  108. emulator: Trace file name is not set  
  109.   
  110.   
  111. emulator: autoconfig: -scale 1  
  112. emulator: control console listening on port 5556, ADB on port 5557  
  113. emulator: can't connect to ADB server: Connection refused  
  114. emulator: ping program: /home/luo/android-4.0.3/out/host/linux-x86/bin/ddms  
  115. emulator: ping command: /home/luo/android-4.0.3/out/host/linux-x86/bin/ddms ping emulator 14.0  
  116. goldfish_fb_get_pixel_format:167: display surface,pixel format:  
  117.   bits/pixel:  16  
  118.   bytes/pixel: 2  
  119.   depth:       16  
  120.   red:         bits=5 mask=0xf800 shift=11 max=0x1f  
  121.   green:       bits=6 mask=0x7e0 shift=5 max=0x3f  
  122.   blue:        bits=5 mask=0x1f shift=0 max=0x1f  

更多Android相关信息见Android 专题页面 http://www.bkjia.com/topicnews.aspx?tid=11

相关内容

    暂无相关文章