Android源码编译汇总

编译步骤

1)切换到下载你的sprdroid源代码目录

$cd xxxxx #xxxx源代码所在地方

2)添加必要的环境变量

$source bulid/envsetup.sh #注意每次切换都需执行此命令,否则,可能导致出现编译找#不到规则等问题

3)选择编译系统版本

$lunch

4)安装kernel header给android编译

$kheader

5)编译

make -j4全编,容易出错,一般会只编译某部分

make bootimage -j4编译镜像

make bootloader -j4编译bootloader

6)在out/target/product/****/目录下出现boot.img、system.img、userdata.img等镜像

编译问题1

编译出现:MODULE.TARGET.APPS.TvQuickSettings already defined by packages/apps/TvSettings/QuickSettings

下载的源码有问题,定位指定的位置发现由于存在重复文件导致的,删除相关文件,得到解决!

编译问题2

Try increasing heap size with java option '-Xmx

export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4g"

./prebuilts/sdk/tools/jack-admin kill-server

./prebuilts/sdk/tools/jack-admin start-server

编译问题3

jack-server服务器无法启动

FAILED: setup-jack-server

Jack server installation not found

No Jack server running. Try ‘jack-admin start-server’

No Jack server running. Try ‘jack-admin start-server’

Jack server failed to (re)start, try ‘jack-diagnose’ or see Jack server log

解决方法:

$ cd

$ sudo mount -o username=ubuntu,password=12cdCD //10.0.1.120/UBTSWCenter /mnt

$ sh /mnt/Ubuntu/1404Ubuntu/jack-server.sh

然后可以进行正常编译

编译问题4

vendor/sprd/proprietories-source/autotest/Android.mk: error: autotest (EXECUTABLES android-arm) missing libwpa_client (SHARED_LIBRARIES android-arm)

You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.

vendor/sprd/proprietories-source/factorytest/Android.mk: error: factorytest (EXECUTABLES android-arm) missing libwpa_client (SHARED_LIBRARIES android-arm)

You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.

解决方法:

rm  vendor/sprd/proprietories-source/autotest/Android.mk vendor/sprd/proprietories-source/factorytest/Android.mk

最后附上Java8的安装

使用ppa/源方式安装java8

1.添加ppa

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

2.安装Oracle-java-installer

jdk7

sudo apt-get install oracle-java7-installer

jdk8

sudo apt-get install oracle-java8-installer

安装器会提示你同意 oracle 的服务条款,选择 ok

然后选择yes 即可

如果你懒,不想自己手动点击.也可以加入下面的这条命令,默认同意条款:

JDK7 默认选择条款

echo oracle-java7-installer shared/accepted-oracle-license-v1-1

select true

|

sudo /usr/bin/debconf-set-selections

JDK8 默认选择条款

echo oracle-java8-installer shared/accepted-oracle-license-v1-1

select true | sudo /usr/bin/debconf-set-selections

接下会是等待(依个人网速定)

如果你因为防火墙或者其他原因,导致installer 下载速度很慢,可以中断操作.然后下载好相应jdk的tar.gz 包,放在:

/var/cache/oracle-jdk7-installer             (jdk7)

/var/cache/oracle-jdk8-installer              (jdk8)

下面,然后安装一次installer. installer 则会默认使用 你下载的tar.gz包

3.设置系统默认jdk

JDk7

sudo update-java-alternatives -s java-7-oracle

JDK8

sudo update-java-alternatives -s java-8-oracle

如果即安装了jdk7,又安装了jdk8,要实现两者的切换,可以:

jdk8 切换到jdk7

sudo update-java-alternatives -s java-7-oracle

jdk7 切换到jdk8

sudo

update-java-alternatives -s java-8-oracle

4.测试jdk 是是否安装成功:

java -version

javac -version

Try increasing heap size with java option '-Xmx

你可能感兴趣的:(Android源码编译汇总)