一.背景
OS: ubuntu 16.04
二.配置交叉编译环境
2.1 安装openjdk
sudo apt-get install openjdk-7-jdk
2.2 使在同一台机器上可以编译android 5.1及以下的版本
sudo /var/lib/dpkg/info/openjdk-7-jdk:amd64.prerm remove
2.3 安装toolslib
sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk3.0-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev pngcrush schedtool libxml2 libxml2-utils xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib libswitch-perl libssl1.0.0 libssl-dev
2.4 源码
git clone https://TeeFirefly@bitbucket.org/T-Firefly/firefly-rk3288.git
2.5 编译内核
cd firefly-rk3288
cd kernel
make firefly-rk3288_defconfig make -j8 firefly-rk3288.img
2.6 编译 Android
make -j8 (默认编译出来的是userdebug版本)
2.6.1 此时出现以下错误:
build/core/main.mk:46: * You are using version 4.1 of make.
build/core/main.mk:47: * Android can only be built by versions 3.81 and 3.82.
2.6.2 解决方案:安装低版本make
wget ftp://ftp.gnu.org/gnu/make/make-3.82.tar.bz2
tar xvf make-3.82.tar.bz2
cd make-3.82
./configure
make
sudo make install
cd /usr/bin
sudo cp make make_back
sudo cp /usr/local/bin/make ./
继续make -j8
2.6.3出现以下错误:
You are attempting to build with an unsupported JDK.
You use OpenJDK but only Sun/Oracle JDK is supported.
2.6.4 解决方案:使用sun/oracle jdk
sudo apt-get update
sudo apt-get remove openjdk* (卸载openjdk)
sudo apt-get install oracle-java6-installer (无法安装)
那么直接下载http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u21-oth-JPR
chmod u+x jdk-6u45-linux-x64.bin
sudo ./jdk-6u45-linux-x64.bin (执行完就出现一目录,将其路径设置到PATH中,如/home/jellojdk/jdk1.6.0_45/bin,那么PATH=/home/jellojdk/jdk1.6.0_45/bin:$PATH)
update-alternatives --display java (当前sdk)
java - 手动模式
link best version is /usr/lib/jvm/java-9-oracle/bin/java
链接目前指向 /usr/lib/jvm/java-9-oracle/bin/java
link java is /usr/bin/java
/usr/lib/jvm/java-9-oracle/bin/java - 优先级 1091
update-alternatives --install /usr/bin/java java /home/jello/jdk/jdk1.6.0_45/bin/java 1092(设置优先级为1092,比1091高)
重新打开一终端,输入java -version 输出如下信息:
jello@jello-Inspiron-N4050:~$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
source build/envsetup.sh
lunch rk3288-eng
继续make -j8
./mkimage.sh