Android编译大全(二)
v 执行ls -la /bin/sh命令,如果输出如下:
rwxrwxrwx 1 root root 4 2010-02-10 17:14 /bin/sh -> dash
请执行$sudo dpkg-reconfigure dash命令修改sh版本,并选择“否”;
此处如果不改好的话,编译时会出现错误。
v 执行source build/envsetup.sh命令
v 执行choosecombo命令,出现选择对话框
u Build for the simulator or the device?
u 1. Device
u 2. Simulator
u
u Which would you like? [1]
u
u Build type choices are:
u 1. release
u 2. debug
u
u Which would you like? [2]
u
u Product choices are:
u 1. core
u 2. full_dream
u 3. full
u 4. full_passion
u 5. full_sapphire
u 6. generic_dream
u 7. generic
u 8. generic_passion
u 9. generic_sapphire
u 10. msm7625_qrd
u 11. msm7627_ffa
u 12. msm7627_surf
u 13. msm7630_surf
u 14. qsd8250_ffa
u 15. qsd8250_surf
u 16. sample_addon
u 17. sdk
u 18. sim
u You can also type the name of a product if you know it.
u Which product would you like? [generic] 3
u
u Variant choices are:
u 1. user
u 2. userdebug
u 3. eng
u Which would you like? [eng]
如果执行这个命令的时候,报错:/bin/sh: Syntax error: “(” unexpected
#请执行$sudo dpkg-reconfigure dash命令,并选择“否”;
v 配置环境变量
export JAVA_HOME=/usr/lib/jvm/java-5-sun
export CLASSPATH=$JAVA_HOME/lib
export JRE_HOME=$JAVA_HOME/jre
export JAVA_PATH=$JAVA_HOME/bin:$JRE_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:
$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export ANDROID_JAVA_HOME=$JAVA_HOME
export PATH=$JAVA_PATH:$PATH
v 执行make命令
如果安装的是java1.6,将报错,如下:
Your version is: java version “1.6.0_15″.
The correct version is: 1.5.
解决java编译错误,如下:
1) 下载jdk1.5(ftp://202.112.80.252/java/jdk-1_5_0_21-linux-i586.bin);
2) 将jdk-1_5_0_21-linux-i586.bin变为可执行权限
$sudo chmod a+x jdk-1_5_0_21-linux-i586.bin
3) 在命令行下执行./jdk-1_5_0_21-linux-i586.bin安装sdk
4) 建立一个软连接到jdk目录
$sudo ln jdk1.5.0_21/ java-5-sun -s
5) 然后配置环境变量:sudo gedit/etc/enviroment在其中添加两行:
CLASSPATH=/usr/lib/jvm/java-5-sun/lib
JAVA_HOME=/usr/lib/jvm/java-5-sun
如果在出现类似使用了旧版api的错误,请先按照提示执行make update-api命令。该命令执行结束之后,再继续执行make命令就可以编译成功了。
在配置好shell命令类型之后,也可以新建一个shell脚本如下,进行自动编译:
export JAVA_HOME=/usr/lib/jvm/java-5-sun
export CLASSPATH=$JAVA_HOME/lib
export JRE_HOME=$JAVA_HOME/jre
export JAVA_PATH=$JAVA_HOME/bin:$JRE_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export ANDROID_JAVA_HOME=$JAVA_HOME
export PATH=$JAVA_PATH:$PATH
source build/envsetup.sh
choosecombo 1 1 7 3
make
build之后的log如下:
… …
creating boot.img…
creating recovery.img…
creating system.img…
creating userdata.img…
cleaning up…
Done.