Orange Pi One(全志 H3)安卓源代码编译总结

入手一块Orange Pi One,然后官方提供的安卓源代码是Android K的,之前我是弄别的项目是编高版本的,比如Android M等等,一开始以为高版本向下兼容,Android M编译是用JDK 7,Android K不支持JDK 7,只能用JDK 6,期间从7改到6遇到不少麻烦,在这里分享一下,希望大家能少走点弯路.

先来说一下编译安卓需要的环境(我是用的Ubuntu),需要安装以下工具:

 1.更新apt源 

        sudo apt-get updata 

 2.安装SSH 

        sudo apt-get install ssh 

 3.安装xchm 

        sudo apt-get install -y xchm 

 4.安装GCC 

        sudo apt-get install -y g++-4.4 gcc-4.4 cpp g++-4.4-multilib gcc-4.4-multilib g++-multilib 

 5.安装gakw 

        sudo apt-get install gawk 

 6安装编译环境 

 6.1安装包 

        sudo apt-get install -y git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5- 
        dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libglapi-mesa:i386 libgl1-mesa-glx 
        libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g- 
        dev:i386 g++-4.4 gcc-4.4 g++-4.4-multilib gcc-4.4-multilib lib32z1-dev libtinfo-dev libncurses5- 

        dev:i386 vim libncursesw5-dev netpbm minicom u-boot-tools libswitch-perl 

 6.2创建链接 

        sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so 

 7.配置GCC 

        cd /usr/bin  
        sudo rm -f gcc  
        sudo rm -f g++  
        sudo ln -s gcc-4.4 gcc  
        sudo ln -s g++-4.4 g++ 

 8.配置静态IP 
         此项较为简单,请自行百度
        
 9.安装Wine工具,用于安装EXE文件 
         sudo apt-get install wine 

 10.配置smb 
 a.      
	sudo apt-get install samba-common smbclient samba 

 b.
	sudo vim /etc/samba/smb.conf 

         [tianfeng]  

         path = /home/tianfeng  

         available = yes 

         browseable = yes  

         writable = yes  

         valid users = tianfeng 
		 
    
 c.配置smb用户
        sudo smbpasswd -a USERNAME (USERNAME 换成你的用户名) 

 11.配置java 
        sudo apt-get install openjdk-7-jdk 

 12.配置Android开发工具 
        sudo apt-get -y install android-tools-adb  
        sudo apt-get -y install android-tools-adbd  
        sudo apt-get -y install android-tools-fastboot 

这样就完成了Android的编译环境的搭建,我以前就是这种搭建环境,现在是要编Android K,是用的JDK 6所以,这里需要本地化一下,再安装一个JDK 6.和fakeroot工具fakeroot_1.18.4.orig.tar.bz2,这两个我有在最下面提供百度云共享.

首先安装fakeroot:

tar xf fakeroot_1.18.4.orig.tar.bz2 
cd fakeroot-1.18.4 
./configure 
make 
make install

然后安装JDK 6:

chmod +x jdk-6u45-linux-x64.bin
./jdk-6u45-linux-x64.bin
mv jdk1.6.0_45/ /usr/lib/jvm

因为现在有了JDK 7和JDK 6,默认用的是JDK 7,我们现在要把环境切换到使用JDK 6,用如下方式:

update-alternatives –install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_45/bin/java 300 
update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 300
update-alternatives –install /usr/bin/javap javap /usr/lib/jvm/jdk1.6.0_45/bin/javap 300 
update-alternatives –install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.6.0_45/bin/javadoc 300

上面配置完之后,我们来把JDK切换到JDK 6,用如下方式:

update-alternatives –config java	// 出现选择信息,选择JDK 6那一项
update-alternatives –config javac	// 出现选择信息,选择JDK 6那一项
update-alternatives –config javap	// 出现选择信息,选择JDK 6那一项
update-alternatives –config javadoc	// 出现选择信息,选择JDK 6那一项

vim ~/.bashrc //修改环境变量, 以便使用java虚拟机. 文件末尾添加如下信息后, 注销一次, 以便生效

       export JAVA_HOME=/usr/lib/jvm/jdk1.6.0_45
       export JRE_HOME=${JAVA_HOME}/jre
       export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
       export PATH=${JAVA_HOME}/bin:$PATH

验证jdk是否配置好: 

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)

然后解压文尾百度云分享的qin2-sync-yunos-v1.0.tar.gz,之后会得到两个文件夹-->lichee 和 android.

进lichee目录里编译uboot, 内核镜像等: 

cd lichee 
./build.sh lunch 
选中2. sun8iw7p1-android-dolphin  // 开始执行编译

编译完成之后,进入android目录:

source ./build/envsetup.sh 
lunch dolphin_fvd_p1-eng 
extract-bsp 
make –j8

编译期间,我遇到了一个报错:

prebuilts/sdk/api/19.txt:23573: error 8: Removed public class android.test.ActivityInstrumentationTestCase
prebuilts/sdk/api/19.txt:23580: error 8: Removed public class android.test.ActivityInstrumentationTestCase2
prebuilts/sdk/api/19.txt:23588: error 8: Removed public class android.test.ActivityTestCase
prebuilts/sdk/api/19.txt:23595: error 8: Removed public class android.test.ActivityUnitTestCase
prebuilts/sdk/api/19.txt:23620: error 8: Removed public class android.test.AndroidTestRunner
prebuilts/sdk/api/19.txt:23641: error 8: Removed public class android.test.ApplicationTestCase
prebuilts/sdk/api/19.txt:23650: error 8: Removed public class android.test.AssertionFailedError
prebuilts/sdk/api/19.txt:23655: error 8: Removed public class android.test.ComparisonFailure
prebuilts/sdk/api/19.txt:23675: error 8: Removed public class android.test.InstrumentationTestRunner
prebuilts/sdk/api/19.txt:23701: error 8: Removed public class android.test.IsolatedContext
prebuilts/sdk/api/19.txt:23706: error 8: Removed public class android.test.LoaderTestCase
prebuilts/sdk/api/19.txt:23711: error 8: Removed public class android.test.MoreAsserts
prebuilts/sdk/api/19.txt:23763: error 8: Removed public class android.test.ProviderTestCase
prebuilts/sdk/api/19.txt:23771: error 8: Removed public class android.test.ProviderTestCase2
prebuilts/sdk/api/19.txt:23779: error 8: Removed public class android.test.RenamingDelegatingContext
prebuilts/sdk/api/19.txt:23788: error 8: Removed public class android.test.ServiceTestCase
prebuilts/sdk/api/19.txt:23801: error 8: Removed public class android.test.SingleLaunchActivityTestCase
prebuilts/sdk/api/19.txt:23807: error 8: Removed public class android.test.SyncBaseInstrumentation
prebuilts/sdk/api/19.txt:23813: error 8: Removed public class android.test.TestSuiteProvider
prebuilts/sdk/api/19.txt:23817: error 8: Removed public class android.test.TouchUtils
prebuilts/sdk/api/19.txt:23855: error 8: Removed public class android.test.ViewAsserts
prebuilts/sdk/api/19.txt:23878: error 7: Removed package android.test.mock
prebuilts/sdk/api/19.txt:24123: error 7: Removed package android.test.suitebuilder
prebuilts/sdk/api/19.txt:32792: error 7: Removed package com.android.internal.util

上面是从网上截取的,实际上可能有些偏差,把实际上错误的地方的相关数据删除就好了,我是报了4个错,然后删除相关位置的那4行,之后执行:

make update-api

然后接着编译,不用make clean,过一会就可以编译完成了:

make -j8

编完之后,执行

pack    // 打包镜像,如果需要串口调试,则打包成pack -d

执行完之后,就有镜像文件了,我们根据提示了路径,找到此镜像文件,然后在windows下用工具PhoenixCard_V310_20130618烧写到sd卡里,就可以正常启动了.

本文借鉴:

https://blog.csdn.net/jklinux/article/details/79378148

https://blog.csdn.net/Hoimk/article/details/57079250

百度云共享文件:

链接:https://pan.baidu.com/s/1-sbiywIO5MnajSGcncCeiQ 密码:7zdf

你可能感兴趣的:(Linux)