参考来源: http://source.android.com/source/initializing.html 或是网上google。
usb部分我是这么配置的:
执行lsusb 差看当前链接到系统的usb设备:
$lsusb
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 002: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 003: ID 0bb4:0c87 High Tech Computer Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
$sudo touch /etc/udev/init.d/51-android.rules $sudo gedit /etc/udev/init.d/51-android.rules增加如下内容(我的手机是htc的, 所以找到High Tech Computer Corp 的idVendor,其他的类似):
SUBSYSTEM=="usb|usb_device", SYSFS{idVendor}=="0bb4", MODE="0666"
重启udev:
$sudo service udev restart关闭adb:
$ ./adb kill-server列出设备:
$ ./adb devices
java部分我是自己从网上下载,然后手动安装的,没有按照google的文档来安装的,这个也可以google的到。
参考来源: http://source.android.com/source/downloading.html
下载repo:
$ mkdir ~/bin $ PATH=~/bin:$PATH
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo $ chmod a+x ~/bin/repo
$ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY初始化 repo:
$ repo init -u https://android.googlesource.com/platform/manifest -b gingerbread同步源代码:
$ repo sync这个阶段时间比较久,网速不行的,就等着痛苦吧,如果失败,从新执行 repo sync
初始化编译环境:
$ source build/envsetup.sh 或 $ . build/envsetup.sh
$ lunch full-enggoogle也给出了这个参数的具体意义,详情请参考 “参考来源”。
编译:
$ makegoogle也给出了 make -jn 其中n表示n个线程来编译,本人经验,最好别用。
接下来就是长时间的等待,如果机器好的话,半个小时左右就可以编译ok了。
编译成功后,会有如下提示:
Target system fs image: out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img Install system fs image: out/target/product/generic/system.img Target ram disk: out/target/product/generic/ramdisk.img Target userdata fs image: out/target/product/generic/userdata.img Installed file list: out/target/product/generic/installed-files.txt
$ ./out/host/linux-x86/bin/emulator -partition-size 256 -kernel prebuilt/android-arm/kernel/kernel-qemu-armv7 -sysdir ~/android/google/gingerbread/out/target/product/generic -system ~/android/google/gingerbread/out/target/product/generic/system.img -data ~/android/google/gingerbread/out/target/product/generic/userdata.img -ramdisk ~/android/google/gingerbread/out/target/product/generic/ramdisk.img -debug-init其中具体路径根据具体的工作目录而变动即可。
下过如下:
下面介绍下如何处理:
参考来源:http://source.android.com/source/known-issues.html
官方给出的解释是由于模拟器太旧了,真是搞不懂,都找到原因了,为什么还不再主干上修改正呢?
如下操作:
$ repo forall external/qemu -c git checkout aosp/tools_r12 $ make $ ./out/host/linux-x86/bin/emulator -partition-size 256 -kernel prebuilt/android-arm/kernel/kernel-qemu-armv7 -sysdir ~/android/google/gingerbread/out/target/product/generic -system ~/android/google/gingerbread/out/target/product/generic/system.img -data ~/android/google/gingerbread/out/target/product/generic/userdata.img -ramdisk ~/android/google/gingerbread/out/target/product/generic/ramdisk.img -debug-init
build/core/base_rules.mk:162: *** sdk/monkeyrunner/etc: MODULE.HOST.EXECUTABLES.monkeyrunner already defined by development/ tools/monkeyrunner/etc. Stop.解决方法:
$repo forall external/qemu -c git checkout aosp/tools_r12 $rm -rf out $source build/envsetup.sh $lunch full-eng $make
$ emulator -version Android emulator version 16.0 (build_id ICS_MR0-234950) Copyright (C) 2006-2011 The Android Open Source Project and many others. This program is a derivative of the QEMU CPU emulator (www.qemu.org). This software is licensed under the terms of the GNU General Public License version 2, as published by the Free Software Foundation, and may be copied, distributed, and modified under those terms. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
$ ./out/host/linux-x86/bin/emulator -version Android emulator version 7.0 (build_id GINGERBREAD-eng.yuchengliu.20120224.102831) Copyright (C) 2006-2011 The Android Open Source Project and many others. This program is a derivative of the QEMU CPU emulator (www.qemu.org). This software is licensed under the terms of the GNU General Public License version 2, as published by the Free Software Foundation, and may be copied, distributed, and modified under those terms. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.