歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 11.04 32位編譯Android 4.0.3

Ubuntu 11.04 32位編譯Android 4.0.3

日期:2017/2/28 15:51:37   编辑:Linux教程

這裡只是記錄一些日志,難免有些錯誤,歡迎批評指正。

環境的建立: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.linuxidc.com @linuxidc:~/android-4.0.3$ export PATH=$PATH:~/android-4.0.3/out/host/linux-x86/bin
www.linuxidc.com @linuxidc:~/android-4.0.3$ export ANDROID_PRODUCT_OUT=~/android-4.0.3/out/target/product/generic
www.linuxidc.com @linuxidc:~/android-4.0.3$ emulator

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

emulator -verbose 可以查看運行過程。

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

更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11

Copyright © Linux教程網 All Rights Reserved