1.编译
在源码下增加编译sdk脚本buildsdk.sh,内容如下:
#!/bin/bash
export JAVA_HOME=/usr/lib/jvm/java-6-oracle
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar:$CLASSPATH
CPU_NUM=$(cat /proc/cpuinfo |grep processor|wc -l)
CPU_NUM=$((CPU_NUM+1))
source build/envsetup.sh
lunch sdk-user
make update-api -j${CPU_NUM}
if [ $? != 0 ]; then
echo "#######error##########"
exit $?
fi
make -j${CPU_NUM}
if [ $? != 0 ]; then
echo "#######error##########"
exit $?
fi
#linux sdk
make PRODUCT-sdk-sdk -j${CPU_NUM}
#win sdk
#make PRODUCT-sdk-win_sdk -j${CPU_NUM}
if [ $? != 0 ]; then
echo "#######error##########"
exit $?
fi
如果电脑中存在多个版本的jdk,前面必需要指定JAVA_HOME等相关环境变量使用update-alternatives --config java无效
如要只有一个版本,脚本前面的三个export行可以删除
修改文件系统源码下:sdk/eclipse/scripts/create_all_symlinks.sh文件
注释掉以下内容:
#if [[ -n "$GRADLE_SWT" ]]; then
# echo "### Starting tools/base: gradlew publishLocal"
# (cd tools/base && ./gradlew publishLocal)
#elif [[ -n "$GRADLE_BASE" ]]; then
# echo "### Starting tools/base: gradlew $GRADLE_BASE"
# (cd tools/base && ./gradlew $GRADLE_BASE)
#fi
# tools/swt: build requested targets
#if [[ -n "$GRADLE_SWT" ]]; then
# echo "### Starting tools/swt: gradlew $GRADLE_SWT"
# (cd tools/swt && ./gradlew $GRADLE_SWT)
#fi
#SRC=$(printGradleJarPath tools/base $SRC)
#SRC=$(printGradleJarPath tools/swt $SRC)
修改sdk/build/tools.atree文件
注释掉以下内容:
# Templates
#tools/base/templates/projects tools/templates/projects
#tools/base/templates/activities tools/templates/activities
#tools/base/templates/gradle tools/templates/gradle
#tools/base/templates/other tools/templates/other
如果是编译windows用sdk
PRODUCT-sdk-win_sdk
还需要安装
apt-get install mingw32
apt-get install tofrodos
安装mingw32需要修改源
sudo gedit /etc/apt/sources.list
//在sources.list末尾添加,保存
deb http://us.archive.ubuntu.com/ubuntu trusty main universe
sudo apt-get update
编译成功后,
win_sdk会在out/host/windows/sdk/下生成
android-sdk_eng.xxx_windows.zip
编译一个记住先保存到别的地方,如果接着编译linux的这个就会被删除
2.使用
如果PC已经安装了SDK,将编译生成的SDK中
build-tools与platforms目录下的文件拷贝到对应的目录中即可.
如果PC没有安装SDK,直接解压就可以使用.
参考链接:http://blog.csdn.net/caz28/article/details/54706646
============================================
作者:hclydao
http://blog.csdn.net/hclydao
版权没有,但是转载请保留此段声明
============================================