1 . 参考android官方网站
======>>>>Ubuntu Linux (32-bit x86)
(1) $ 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
安装如下开发环境必需软件:(sun-java5-jdk应该找不到,可暂时不安装,下面会说明)
o Git 1.5.4 or newer and the GNU Privacy Guard.
o JDK 5.0, update 12 or higher.Java 6 is not supported, because of incompatibilities with @Override.
o flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl.
(2) $ sudo apt-get install valgrind
(3)$ sudo apt-get install lib32readline5-dev
======>>>>Ubuntu Linux (64-bit x86) 如果安装linux 64位
(1) $ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev
(2) $ sudo update-java-alternatives -s java-1.5.0-sun
(3)$ sudo ln -s /usr/lib32/libX11.so.6 /usr/lib32/libX11.so
2. 安装 Repo( 下载代码工具)
Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see Using Repo and Git .
To install, initialize, and configure Repo, follow these steps:
(1. Make sure you have a~/bindirectory in your home directory, and check to be sure that this bin directory is in your path:
$ cd ~
$ mkdir bin ($ export PATH=$PATH:/home/zhengmingsang/bin)
$ echo $PATH
(2. Download thereposcript and make sure it is executable:
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
3. Initializing a Repo client(其实就是下载开源android开发代码,如果自己有开发源码,这一步可忽略)
(1. Create an empty directory to hold your working files:
$ mkdir mydroid
$ cd mydroid
(2. Run "repo init" to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest:
$ repo init -u git://android.git.kernel.org/platform/manifest.git
* If you would like to check out a branch other than "master", specify it with -b, like:
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
(3. When prompted, configure Repo with your real name and email address. If you plan to submit code, use an email address that is associated with a Google account .
A successful initialization will end with a message such as
repo initialized in /mydroid
To pull down files to your working directory from the repositories as specified in the default manifest, run
$ repo sync (这一步需要很长时间)
Verifying Git Tags
Load the following public key into your GnuPG key database.The key is used to sign annotated tags that represent releases.
$ gpg --import
then paste the key(s) below, and press Control-D to end the input and process the keys. After importing the keys, you can verify any tag with
$ git tag -v tagname
4. 安装上面提到的sun-java5-jdk(ubuntu10.04源自带的版本是java1.6,编译android可能会有问题)
早在ubuntu 9.10中,ubuntu就已经去除了对sun-java5-jdk的支持,但是为了进行android的开发,又必须安装sun- java5-jdk。那么在享受ubuntu 10.04好处的同时,如何来进行sun-java5-jdk的安装那。经过多次的摸索,下面是一个方案:
(1.编辑/etc/apt/sources.list文件,将安装源更改为ubuntu 9.04的安装源为: sudo apt-get update
deb http://tw.archive.Ubuntu.com/ubuntu jaunty main restricted universe multiverse
deb http://tw.archive.Ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
deb http://tw.archive.Ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
deb http://tw.archive.Ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
deb http://tw.archive.Ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse
(2.安装java5,apt-get install sun-java5-jdk.
(3.更改默认jdk的方法如下:
update-alternatives --config java
显示如下,然后键入java- 1.5.0-sun的编号:
有 2 个选项可用于替换项 java (提供 /usr/bin/java)。
选择 路径 优先级 状态
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 自动模式
1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java 53 手动模式
2 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 手动模式
要维持当前值[*]请按回车键,或者键入选择的编号:1
5.查看当前的java版本:
java -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode, sharing)
同理,更改默认的javac,方法为update-alternatives --config javac.
接着就可以进行android的编译了。
一切顺利,世界终于太平了!
6. 可能会遇到的问题总结
Building the code
To build the files, runmakefrom within your working directory:
$ cd ~/mydroid
$ make
(1)If your build fails, complaining about a missing "run-java-tool", try setting the ANDROID_JAVA_HOME env var to $JAVA_HOME before making.E.g.,
$ export ANDROID_JAVA_HOME=$JAVA_HOME
(2)问题:Ubuntu 升级为 9.10, 后 Android 源码无法编译通过怎么办?
原因:
这是 gcc 和 g++ 的版本太高导致的问题。Ubuntu 9.04 是4.3, 而 9.10 是4.4.
GCC 在 4.4 时把部份 string 相关的 function 回传值的 type 改变了...
char* 改成了 const char*...
也因此让一堆原本不是针对最新的gcc来写的code都无法编译成功。
解决方案:使用旧版本的 gcc 和 g++ 。
1、先下载 gcc-4.3 g++-4.3:
源码打印?
1. apt-get install gcc-4.3 g++-4.3
apt-get install gcc-4.3 g++-4.3
2、删除原有的连接:
源码打印?
1. sudo rm /usr/bin/gcc<br>sudo rm /usr/bin/g++
sudo rm /usr/bin/gcc
sudo rm /usr/bin/g++
3、添加新的连接:
源码打印?
1. sudo ln -s /usr/bin/gcc-4.3 /usr/bin/gcc<br>sudo ln -s /usr/bin/g++-4.3 /usr/bin/g++
sudo ln -s /usr/bin/gcc-4.3 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.3 /usr/bin/g++
(3)问题:Ubuntu 中没有 Android 要求的 jdk 1.5, 怎么办?
解决方案一:安装 jdk 1.5。
方法1:从官方网站上下载 jdk 1.5,安装。
方法2:在 /etc/apt/sources.list 中添加 9.04 的源:
deb http://mirrors.163.com/ubuntu/ jaunty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jaunty-updates main restricted universe multiverse
更新源,安装 jdk 1.5。
解决方案二:如果您已经安装了 jdk 1.6, 请修改 <src_home>/build/core/make.mk。(注,如果是 2.0 版本的源码,请修改 <src_home>/build/core/main.mk)
在文件中搜索并分别把:
源码打印?
1. java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1/.5[/. "$$]')<br>javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1/.5[/. "$$]')
java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1/.5[/. "$$]')
javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1/.5[/. "$$]')
两行改成:
源码打印?
1. java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1/.6[/. "$$]')<br>javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1/.6[/. "$$]')
java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1/.6[/. "$$]')
javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1/.6[/. "$$]')
即可。
如果你有其它的开发要使用 jdk 1.6 的话,采用解决方案二是一种不错的选择,它可以避免你在两个 jdk 之间切换。
==================================================
以上方案,在 Ubuntu 9.10 + Android 2.1 环境中测试通过。即正确编译 Android 2.1 源码通过。
注意:
1、对于第二个问题的 解决方案二 请谨慎采用。由于修改了 Android 原配置文件,对编译结果的影响未知,建议经详细测试后再用于商业目的编译(要不然,出了问题可别找我哈,呵呵)。
不过到目前为止,我编译出来的结果文件,没有出现任何异常。如果大家发现了问题,不妨回复分享一下。
2、如果需要 make sdk,则需要把 javadoc 设置为 1.5 的。
安装 javadoc 1.5版本,然后 sudo update-alternatives --config javadoc,选择 1.5 版本。
不然会出现以下错误:
源码打印?
1. javadoc: 错误 - 在 doclet 类 DroidDoc 中,方法 start 已抛出异常 java.lang.reflect.InvocationTargetException<br>com.sun.tools.javac.code.Symbol$CompletionFailure: 未找到 sun.util.resources.OpenListResourceBundle 的类文件<br>1 错误<br>make: *** [out/target/common /docs/services-timestamp] 错误 45
javadoc: 错误 - 在 doclet 类 DroidDoc 中,方法 start 已抛出异常 java.lang.reflect.InvocationTargetException
com.sun.tools.javac.code.Symbol$CompletionFailure: 未找到 sun.util.resources.OpenListResourceBundle 的类文件
1 错误
make: *** [out/target/common/docs/services-timestamp] 错误 45
金宝博:122.252.25.188
==================================================
解决了以上两个问题之后,按照 Android 官方文档的方法即可顺利进行编译。分享经验,分享快乐!放心享受 Ubuntu 9.10 带给您的惊喜吧!
作者:曾赛
日期:2010-02-25
====================
补充:常见问题解决方案
====================
1.找不到PRODUCT_POLICY
frameworks/policies/base/PolicyConfig.mk:22: *** No module defined for the given PRODUCT_POLICY (android.policy_phone).
解法: 修改build/tools/findleaves.sh的89行:
#find "${@:0:$nargs}" $findargs -type f -name "$filename" -print |
find "${@:1:$nargs-1}" $findargs -type f -name "$filename" -print |
2. fprintf未定义
frameworks/base/tools/aidl/AST.cpp:10: error: 'fprintf' was not declared in
this scope
解法:apt-get install gcc-4.3 g++-4.3,并重新ln gcc 和g++到 gcc-4.3 和g++-4.3
3.安装sun- java6-jdk,并且在环境变量中设置:
export JAVA_HOME=/usr/lib/jvm/java-6-sun/
export ANDROID_JAVA_HOME=$JAVA_HOME
这部分摘自:http://embeddeder.spaces.live.com/Blog/cns!8006E36532087D51!213.entry
附后:(from http://forum.xda-developers.com/archive/index.php/t-633274.html)
I notice that there is quiet a few people around that are having issues building the source, due to the lack on Sun-Java5 (1.5 JDK) in the Ubuntu Repositories.
In a hope it will encourage more developers, I'll post the following, which will build a full eclair system, on a new Ubuntu 9.10 x64 system.
源码打印?
1. $ mkdir ~/mydroid
2. $ mkdir mydroid/java5-packages
3. $ cd ~mydroid/java5-packages
4. $ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jre_1.5.0-18-1_all.deb
5. $ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-bin_1.5.0-18-1_amd64.deb
6. $ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-demo_1.5.0-18-1_amd64.deb
7. $ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jdk_1.5.0-18-1_amd64.deb
8. $ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev java-common unixodbc
9. $ sudo dpkg -i --ignore-depends=sun-java5-bin sun-java5-jre_1.5.0-18-1_all.deb
10. $ sudo dpkg -i sun-java5-bin_1.5.0-18-1_amd64.deb
11. $ sudo dpkg -i --ignore-depends=sun-java5-jdk sun-java5-demo_1.5.0-18-1_amd64.deb
12. $ sudo dpkg -i sun-java5-jdk_1.5.0-18-1_amd64.deb
13. $ sudo update-java-alternatives -s java-1.5.0-sun
14. $ cd ..
15. $ wget http://android.git.kernel.org/repo
16. $ sudo mv repo /usr/bin/
17. $ chmod a+x /usr/bin/repo
18. $ repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair
19. $ rep sync
20. $ cd external/webkit/
21. $ git cherry-pick 18342a41ab72e2c21931afaaab6f1b9bdbedb9fa
22. $ cd ../../
23. $ wget --referer=http://developer.htc.com/google-io-device.html http://member.america.htc.com/download/RomCode/ADP/signed-google_ion-ota-14721.zip?
24. $ cd vendor/htc/sapphire-open/
25. $ ./unzip-files.sh
26. $ cd ../../../
27. $ . build/envsetup.sh
28. $ lunch aosp_sapphire_us-eng
29. $ make
$ mkdir ~/mydroid
$ mkdir mydroid/java5-packages
$ cd ~mydroid/java5-packages
$ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jre_1.5.0-18-1_all.deb
$ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-bin_1.5.0-18-1_amd64.deb
$ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-demo_1.5.0-18-1_amd64.deb
$ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jdk_1.5.0-18-1_amd64.deb
$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev java-common unixodbc
$ sudo dpkg -i --ignore-depends=sun-java5-bin sun-java5-jre_1.5.0-18-1_all.deb
$ sudo dpkg -i sun-java5-bin_1.5.0-18-1_amd64.deb
$ sudo dpkg -i --ignore-depends=sun-java5-jdk sun-java5-demo_1.5.0-18-1_amd64.deb
$ sudo dpkg -i sun-java5-jdk_1.5.0-18-1_amd64.deb
$ sudo update-java-alternatives -s java-1.5.0-sun
$ cd ..
$ wget http://android.git.kernel.org/repo
$ sudo mv repo /usr/bin/
$ chmod a+x /usr/bin/repo
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair
$ rep sync
$ cd external/webkit/
$ git cherry-pick 18342a41ab72e2c21931afaaab6f1b9bdbedb9fa
$ cd ../../
$ wget --referer=http://developer.htc.com/google-io-device.html http://member.america.htc.com/download/RomCode/ADP/signed-google_ion-ota-14721.zip?
$ cd vendor/htc/sapphire-open/
$ ./unzip-files.sh
$ cd ../../../
$ . build/envsetup.sh
$ lunch aosp_sapphire_us-eng
$ make
That's it? Ok, So it was a lot... Hope this helps someone get the 1.5 JDK on their Ubuntu system (and build eclair)
(4).
ubuntu10.04 问题论坛地址:http://www.linuxidx.com/linux.php?q=Ubuntu10.04+%E5%AE%89%E8%A3 %85%E6%96%B0%E7%89%88Wine
将源码编译完后下一步的动作就是要看看效果了,怎样启动模拟器是一个问题。网上有很多种做法,下面介绍一种简单的方式进行处理。
在下载源码的目录下,make sdk命令,编译sdk。而后在/home/stone/working-directory-name/out/host/linux-x86多
一个 sdk目录。在sdk的 tools目录下使用命令创建虚拟设备,此时创建方式和1.5有所不同其命令是:
./android list targets
./android create avd -n sphone -t android-7
2.1版本的要求其 targetid 必须是 android-7这种模式。
而后启动模拟器:
命令是:
./emulator -avd sphone
至此关于android源码下载、编译、模拟器运行的基本知识介绍完毕。下步就是深入分析其源码。
在这个过程中下载源码大约下了8个小时,编译源码用了3个小时,编译sdk用时20分钟。就是这样等待中见证欣喜。
$ sudo apt-get install valgrind
* Intrepid ( 8.10) users may need a newer version of libreadline:
$ sudo apt-get install lib32readline5-dev
Ubuntu Linux (64-bit x86)
This has not been as well tested. Please send success or failure reports to android-porting@googlegroups.com .
The Android build requires a 32-bit build environment as well as some other tools:
* Required Packages:
o Git, JDK, flex, and the other packages as listed above in the i386 instructions:
o JDK 5.0, update 12 or higher.Java 6 is not supported, because of incompatibilities with @Override.
o Pieces from the 32-bit cross-building environment
o X11 development
$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev
* Set the system to use the right version of java by default:
$ sudo update-java-alternatives -s java-1.5.0-sun
* X11: Ubuntu doesn't have packages for the X11 libraries, but that can be worked around with the following command:
$ sudo ln -s /usr/lib32/libX11.so.6 /usr/lib32/libX11.so
Installing Repo
Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see Using Repo and Git .
To install, initialize, and configure Repo, follow these steps:
1. Make sure you have a~/bindirectory in your home directory, and check to be sure that this bin directory is in your path:
$ cd ~
$ mkdir bin ($ export PATH=$PATH:/home/zhengmingsang/bin)
$ echo $PATH
2. Download thereposcript and make sure it is executable:
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
Initializing a Repo client
1. Create an empty directory to hold your working files:
$ mkdir mydroid
$ cd mydroid
2. Run "repo init" to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest:
$ repo init -u git://android.git.kernel.org/platform/manifest.git
* If you would like to check out a branch other than "master", specify it with -b, like:
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
3. When prompted, configure Repo with your real name and email address. If you plan to submit code, use an email address that is associated with a Google account .
A successful initialization will end with a message such as
repo initialized in /mydroid
To pull down files to your working directory from the repositories as specified in the default manifest, run
$ repo sync
Verifying Git Tags
Load the following public key into your GnuPG key database.The key is used to sign annotated tags that represent releases.
$ gpg --import
then paste the key(s) below, and press Control-D to end the input and process the keys. After importing the keys, you can verify any tag with
$ git tag -v tagname
(2).
早在ubuntu 9.10中,ubuntu就已经去除了对sun-java5-jdk的支持,但是为了进行android的开发,又必须安装sun- java5-jdk。那么在享受ubuntu 10.04好处的同时,如何来进行sun-java5-jdk的安装那。经过多次的摸索,下面是一个方案:
1.编辑/etc/apt/sources.list文件,将安装源更改为ubuntu 9.04的安装源为: sudo apt-get update
deb http://tw.archive.Ubuntu.com/ubuntu jaunty main restricted universe multiverse
deb http://tw.archive.Ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
deb http://tw.archive.Ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
deb http://tw.archive.Ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
deb http://tw.archive.Ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
deb-src http://tw.archive.Ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse
2.安装java5,apt-get install sun-java5-jdk.
4.更改默认jdk的方法如下:
update-alternatives --config java
显示如下,然后键入java- 1.5.0-sun的编号:
有 2 个选项可用于替换项 java (提供 /usr/bin/java)。
选择 路径 优先级 状态
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 自动模式
1 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java 53 手动模式
2 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 手动模式
要维持当前值[*]请按回车键,或者键入选择的编号:1
5.查看当前的java版本:
java -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode, sharing)
同理,更改默认的javac,方法为update-alternatives --config javac.
接着就可以进行android的编译了。
一切顺利,世界终于太平了!
///
Building the code
To build the files, runmakefrom within your working directory:
$ cd ~/mydroid
$ make
If your build fails, complaining about a missing "run-java-tool", try setting the ANDROID_JAVA_HOME env var to $JAVA_HOME before making.E.g.,
$ export ANDROID_JAVA_HOME=$JAVA_HOME
///
(3).
http://my.oschina.net/zengsai/blog/2903
==========================================
如何在 Ubuntu 9.10 下编译 Android 源码
==========================================
问题:Ubuntu 升级为 9.10, 后 Android 源码无法编译通过怎么办?
原因:
这是 gcc 和 g++ 的版本太高导致的问题。Ubuntu 9.04 是4.3, 而 9.10 是4.4.
GCC 在 4.4 时把部份 string 相关的 function 回传值的 type 改变了...
char* 改成了 const char*...
也因此让一堆原本不是针对最新的gcc来写的code都无法编译成功。
解决方案:使用旧版本的 gcc 和 g++ 。
1、先下载 gcc-4.3 g++-4.3:
源码打印?
1. apt-get install gcc-4.3 g++-4.3
apt-get install gcc-4.3 g++-4.3
2、删除原有的连接:
源码打印?
1. sudo rm /usr/bin/gcc<br>sudo rm /usr/bin/g++
sudo rm /usr/bin/gcc
sudo rm /usr/bin/g++
3、添加新的连接:
源码打印?
1. sudo ln -s /usr/bin/gcc-4.3 /usr/bin/gcc<br>sudo ln -s /usr/bin/g++-4.3 /usr/bin/g++
sudo ln -s /usr/bin/gcc-4.3 /usr/bin/gcc
sudo ln -s /usr/bin/g++-4.3 /usr/bin/g++
==================================================
问题:Ubuntu 中没有 Android 要求的 jdk 1.5, 怎么办?
解决方案一:安装 jdk 1.5。
方法1:从官方网站上下载 jdk 1.5,安装。
方法2:在 /etc/apt/sources.list 中添加 9.04 的源:
deb http://mirrors.163.com/ubuntu/ jaunty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ jaunty-updates main restricted universe multiverse
更新源,安装 jdk 1.5。
解决方案二:如果您已经安装了 jdk 1.6, 请修改 <src_home>/build/core/make.mk。(注,如果是 2.0 版本的源码,请修改 <src_home>/build/core/main.mk)
在文件中搜索并分别把:
源码打印?
1. java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1/.5[/. "$$]')<br>javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1/.5[/. "$$]')
java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1/.5[/. "$$]')
javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1/.5[/. "$$]')
两行改成:
源码打印?
1. java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1/.6[/. "$$]')<br>javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1/.6[/. "$$]')
java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1/.6[/. "$$]')
javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1/.6[/. "$$]')
即可。
如果你有其它的开发要使用 jdk 1.6 的话,采用解决方案二是一种不错的选择,它可以避免你在两个 jdk 之间切换。
==================================================
以上方案,在 Ubuntu 9.10 + Android 2.1 环境中测试通过。即正确编译 Android 2.1 源码通过。
注意:
1、对于第二个问题的 解决方案二 请谨慎采用。由于修改了 Android 原配置文件,对编译结果的影响未知,建议经详细测试后再用于商业目的编译(要不然,出了问题可别找我哈,呵呵)。
不过到目前为止,我编译出来的结果文件,没有出现任何异常。如果大家发现了问题,不妨回复分享一下。
2、如果需要 make sdk,则需要把 javadoc 设置为 1.5 的。
安装 javadoc 1.5版本,然后 sudo update-alternatives --config javadoc,选择 1.5 版本。
不然会出现以下错误:
源码打印?
1. javadoc: 错误 - 在 doclet 类 DroidDoc 中,方法 start 已抛出异常 java.lang.reflect.InvocationTargetException<br>com.sun.tools.javac.code.Symbol$CompletionFailure: 未找到 sun.util.resources.OpenListResourceBundle 的类文件<br>1 错误<br>make: *** [out/target/common /docs/services-timestamp] 错误 45
javadoc: 错误 - 在 doclet 类 DroidDoc 中,方法 start 已抛出异常 java.lang.reflect.InvocationTargetException
com.sun.tools.javac.code.Symbol$CompletionFailure: 未找到 sun.util.resources.OpenListResourceBundle 的类文件
1 错误
make: *** [out/target/common/docs/services-timestamp] 错误 45
金宝博:122.252.25.188
==================================================
解决了以上两个问题之后,按照 Android 官方文档的方法即可顺利进行编译。分享经验,分享快乐!放心享受 Ubuntu 9.10 带给您的惊喜吧!
作者:曾赛
日期:2010-02-25
====================
补充:常见问题解决方案
====================
1.找不到PRODUCT_POLICY
frameworks/policies/base/PolicyConfig.mk:22: *** No module defined for the given PRODUCT_POLICY (android.policy_phone).
解法: 修改build/tools/findleaves.sh的89行:
#find "${@:0:$nargs}" $findargs -type f -name "$filename" -print |
find "${@:1:$nargs-1}" $findargs -type f -name "$filename" -print |
2. fprintf未定义
frameworks/base/tools/aidl/AST.cpp:10: error: 'fprintf' was not declared in
this scope
解法:apt-get install gcc-4.3 g++-4.3,并重新ln gcc 和g++到 gcc-4.3 和g++-4.3
3.安装sun- java6-jdk,并且在环境变量中设置:
export JAVA_HOME=/usr/lib/jvm/java-6-sun/
export ANDROID_JAVA_HOME=$JAVA_HOME
这部分摘自:http://embeddeder.spaces.live.com/Blog/cns!8006E36532087D51!213.entry
附后:(from http://forum.xda-developers.com/archive/index.php/t-633274.html)
I notice that there is quiet a few people around that are having issues building the source, due to the lack on Sun-Java5 (1.5 JDK) in the Ubuntu Repositories.
In a hope it will encourage more developers, I'll post the following, which will build a full eclair system, on a new Ubuntu 9.10 x64 system.
源码打印?
1. $ mkdir ~/mydroid
2. $ mkdir mydroid/java5-packages
3. $ cd ~mydroid/java5-packages
4. $ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jre_1.5.0-18-1_all.deb
5. $ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-bin_1.5.0-18-1_amd64.deb
6. $ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-demo_1.5.0-18-1_amd64.deb
7. $ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jdk_1.5.0-18-1_amd64.deb
8. $ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev java-common unixodbc
9. $ sudo dpkg -i --ignore-depends=sun-java5-bin sun-java5-jre_1.5.0-18-1_all.deb
10. $ sudo dpkg -i sun-java5-bin_1.5.0-18-1_amd64.deb
11. $ sudo dpkg -i --ignore-depends=sun-java5-jdk sun-java5-demo_1.5.0-18-1_amd64.deb
12. $ sudo dpkg -i sun-java5-jdk_1.5.0-18-1_amd64.deb
13. $ sudo update-java-alternatives -s java-1.5.0-sun
14. $ cd ..
15. $ wget http://android.git.kernel.org/repo
16. $ sudo mv repo /usr/bin/
17. $ chmod a+x /usr/bin/repo
18. $ repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair
19. $ rep sync
20. $ cd external/webkit/
21. $ git cherry-pick 18342a41ab72e2c21931afaaab6f1b9bdbedb9fa
22. $ cd ../../
23. $ wget --referer=http://developer.htc.com/google-io-device.html http://member.america.htc.com/download/RomCode/ADP/signed-google_ion-ota-14721.zip?
24. $ cd vendor/htc/sapphire-open/
25. $ ./unzip-files.sh
26. $ cd ../../../
27. $ . build/envsetup.sh
28. $ lunch aosp_sapphire_us-eng
29. $ make
$ mkdir ~/mydroid
$ mkdir mydroid/java5-packages
$ cd ~mydroid/java5-packages
$ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jre_1.5.0-18-1_all.deb
$ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-bin_1.5.0-18-1_amd64.deb
$ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-demo_1.5.0-18-1_amd64.deb
$ wget http://mirror.pacific.net.au/linux/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jdk_1.5.0-18-1_amd64.deb
$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev java-common unixodbc
$ sudo dpkg -i --ignore-depends=sun-java5-bin sun-java5-jre_1.5.0-18-1_all.deb
$ sudo dpkg -i sun-java5-bin_1.5.0-18-1_amd64.deb
$ sudo dpkg -i --ignore-depends=sun-java5-jdk sun-java5-demo_1.5.0-18-1_amd64.deb
$ sudo dpkg -i sun-java5-jdk_1.5.0-18-1_amd64.deb
$ sudo update-java-alternatives -s java-1.5.0-sun
$ cd ..
$ wget http://android.git.kernel.org/repo
$ sudo mv repo /usr/bin/
$ chmod a+x /usr/bin/repo
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair
$ rep sync
$ cd external/webkit/
$ git cherry-pick 18342a41ab72e2c21931afaaab6f1b9bdbedb9fa
$ cd ../../
$ wget --referer=http://developer.htc.com/google-io-device.html http://member.america.htc.com/download/RomCode/ADP/signed-google_ion-ota-14721.zip?
$ cd vendor/htc/sapphire-open/
$ ./unzip-files.sh
$ cd ../../../
$ . build/envsetup.sh
$ lunch aosp_sapphire_us-eng
$ make
That's it? Ok, So it was a lot... Hope this helps someone get the 1.5 JDK on their Ubuntu system (and build eclair)
(4).
ubuntu10.04 问题论坛地址:http://www.linuxidx.com/linux.php?q=Ubuntu10.04+%E5%AE%89%E8%A3 %85%E6%96%B0%E7%89%88Wine
将源码编译完后下一步的动作就是要看看效果了,怎样启动模拟器是一个问题。网上有很多种做法,下面介绍一种简单的方式进行处理。
在下载源码的目录下,make sdk命令,编译sdk。而后在/home/stone/working-directory-name/out/host/linux-x86多
一个 sdk目录。在sdk的 tools目录下使用命令创建虚拟设备,此时创建方式和1.5有所不同其命令是:
./android list targets
./android create avd -n sphone -t android-7
2.1版本的要求其 targetid 必须是 android-7这种模式。
而后启动模拟器:
命令是:
./emulator -avd sphone
至此关于android源码下载、编译、模拟器运行的基本知识介绍完毕。下步就是深入分析其源码。
在这个过程中下载源码大约下了8个小时,编译源码用了3个小时,编译sdk用时20分钟。就是这样等待中见证欣喜。