Android source开发环境搭建
眾所周知,Android是開源的。這樣就可以下載Android的全部代碼,進行編譯生成二進制鏡象文件。
開發平臺
Ubuntu.
工具安裝
$ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf
??? libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl
??? libncurses5-dev zlib1g-dev
源碼下載
$ cd ~
$ mkdir bin
$ curl http://android.git.kernel.org/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
repo是一個工具,用來配合Git下載源碼的。
$ export PATH=$HOME/bin:$PATH
$ mkdir mydroid
$ cd mydroid
$ repo init –u git://android.git.kernel.org/platform/manifest.git –b [BRANCH_NAME]
$ repo sync
編譯生成
$ cd mydroid
$ make
官方指導可訪問:http://source.android.com/source/download.html
另一篇可參考的文章:http://mmmyddd.freeshell.net/wiki/android/build.html
運行模擬器
要運行模擬器,至少需要4個images:
- system.img?? : the *initial* system image.
- ramdisk.img? : the ramdisk image used to boot the system.
- userdata.img : the *initial* user data image (see below).
- kernel-qemu? : the emulator-specific Linux kernel image.
編譯完成后,生成的system.img,ramdisk.img,userdata.img在目錄<src_directory>/out/target/product/generic/下。
kernel-qemu在目錄<src_directory>/prebuilt/android-arm/kernel/下。
模擬器啟動時,自動在路徑<src_directory>/prebuilt/android-arm/kernel/下查找kernel-qemu,但還要用戶顯示指明另外3個images的路徑。模擬器通過查看環境變量ANDROID_PRODUCT_OUT來確定另外3個images的路徑。因此,啟動前先設置export ANDROID_PRODUCT_OUT=<src_directory>/out/target/product/generic。
設置好環境變量后,切換到<src_directory>/out/host/linux-x86/bin/目錄,運行./emulator 就可以加載生成的images運行Android系統了。
如果在運行emulator時出現諸如“emulator: ERROR: There is no user data image in your build directory. Please make a full build”的錯誤,請先檢查文件的權限。
emulator相關的文檔:
ray@ray-ubuntu:~/android_2_2/out/host/linux-x86/bin$ ./emulator -help-build-images
? The emulator detects that you are working from the Android build system
? by looking at the ANDROID_PRODUCT_OUT variable in your environment.
? If it is defined, it should point to the product-specific directory that
? contains the generated system images.
? In this case, the emulator will look by default for the following image
? files there:
??? - system.img?? : the *initial* system image.
??? - ramdisk.img? : the ramdisk image used to boot the system.
??? - userdata.img : the *initial* user data image (see below).
??? - kernel-qemu? : the emulator-specific Linux kernel image.
? If the kernel image is not found in the out directory, then it is searched
? in <build-root>/prebuilt/android-arm/kernel/.
? Skins will be looked in <build-root>/sdk/emulator/skins/
? You can use the -sysdir, -system, -kernel, -ramdisk, -datadir, -data options
? to specify different search directories or specific image files. You can
? also use the -cache and -sdcard options to indicate specific cache partition
? and SD Card image files.
? For more details, see the corresponding -help-<option> section.
? Note that the following behaviour is specific to 'build mode':
? - the *initial* system image is copied to a temporary file which is
??? automatically removed when the emulator exits. There is thus no way to
??? make persistent changes to this image through the emulator, even if
??? you use the '-image <file>' option.
? - unless you use the '-cache <file>' option, the cache partition image
??? is backed by a temporary file that is initially empty and destroyed on
??? program exit.
? SPECIAL NOTE: If you are using the emulator with the Android SDK, the
? information above doesn't apply. See -help-sdk-images for more details.
轉載于:https://www.cnblogs.com/RayLee/archive/2010/11/23/1885482.html
總結
以上是生活随笔為你收集整理的Android source开发环境搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: jquery 学习之二 属性---文本
- 下一篇: Android UI开发第二篇——多级