ubuntu 14.10 编译 android 4.4kitkat


由于在windows下开发luncher比较麻烦,决定转到在linux下开发,自己编译源码。

以下是安装过程中遇到的问题,需要一一解决:


1

Android can only be built by versions 3.81 and 3.82

 

删除高版本的make 4.0.8,编译安装低版本make 3.81

 

下载make 3.81源码

参考make下的READMEINSTALL文件,安装make 3.81

 

 

 

2、 JDK发布方和版本问题

You are attempting to build with an unsupported JDK.

You use OpenJDK but only Sun/Oracle JDK is supported.

 

卸载OpenJDK  apt-get remove openjdk*

安装Sun/Oracle JDK 

 

http://blog.csdn.net/tecn14/article/details/24797545 方法

http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR 下载JDK6地址

 

下面开始安装jdk: 

在把jdk安装在/usr/lib/jdk下面,

终端下进入你存放jdk-6u37-linux-x64.bin的/home/wr/software/

 

$sudo chmod 777 jdk-6u37-linux-x64.bin // 将文件赋于运行权限

$ sudo -s ./jdk-6u37-linux-x64.bin /usr/lib/jdk 

 

解出来还是在/home/wr/software/目录下,不纠结于此,直接配置环境变量:

etc/environment : 

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/wr/software/jdk1.6.0_45/bin"

CLASSPATH="/home/wr/software/jdk1.6.0_45/lib:."

JAVA_HOME="/home/wr/software/jdk1.6.0_45/"

 

 

3、  i686-linux-gcc问题

 

漏掉了gcc相关包

安装gcc-multilib

 

 

4、  libz.so

/home/wr/Android/android_kitkat/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/../lib/gcc/i686-linux/4.6.x-google/../../../../i686-linux/bin/as: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

 

没有安装libz.so.1相关的工具包

安装apt-file : sudo apt-get install apt-file

然后apt-file update

 

apt-file search libz.so

lib32z1: /usr/lib32/libz.so.1

lib32z1: /usr/lib32/libz.so.1.2.8

lib32z1-dev: /usr/lib32/libz.so

libx32z1: /usr/libx32/libz.so.1

libx32z1: /usr/libx32/libz.so.1.2.8

libx32z1-dev: /usr/libx32/libz.so

zlib1g: /lib/x86_64-linux-gnu/libz.so.1

zlib1g: /lib/x86_64-linux-gnu/libz.so.1.2.8

zlib1g-dev: /usr/lib/x86_64-linux-gnu/libz.so

 

 

依次安装lib32z1 ib32z1-dev lsb-build-base3 zlib1g-dbg等等

 

 

5

Yacc: aidl <= frameworks/base/tools/aidl/aidl_language_y.y

prebuilts/misc/linux-x86/bison/bison -d  -o out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp frameworks/base/tools/aidl/aidl_language_y.y

make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_y.cpp] 断开的管道

 

解决:

sudo apt-get install bison

 

 

6

Lex: aidl <= frameworks/base/tools/aidl/aidl_language_l.l

/bin/bash: flex: 未找到命令

make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] 错误 127

 

解决:

sudo apt-get install flex

 

 

7

  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child

    raise child_exception

OSError: [Errno 2] No such file or directory

make: *** [out/target/product/generic/obj/GYP/shared_intermediates/blink/CSSPropertyNames.cpp] 错误 1

 

确认并安装了以下环境:

git gnupg flex bison gperf build-essential   zip curl libc6-dev x11proto-core-dev   g++-multilib  tofrodos   python-markdown libxml2-utils xsltproc

确认漏装了:

gperf build-essential x11proto-core-dev g++-multilib tofrodos python-markdown libxml2-utils xsltproc

 

 

http://blog.chinaunix.net/uid-25737580-id-3150901.html

 

编译完成后,在source目录下会生成一个out文件夹,在out/target/product/generic/下是生成的system.img,ramdisk.img,userdata.img.

 

 

00

============================================

PLATFORM_VERSION_CODENAME=REL

PLATFORM_VERSION=4.4

TARGET_PRODUCT=full

TARGET_BUILD_VARIANT=eng

TARGET_BUILD_TYPE=release

TARGET_BUILD_APPS=

TARGET_ARCH=arm

TARGET_ARCH_VARIANT=armv7-a

TARGET_CPU_VARIANT=generic

HOST_ARCH=x86

HOST_OS=linux

HOST_OS_EXTRA=Linux-3.16.0-28-generic-x86_64-with-Ubuntu-14.10-utopic

HOST_BUILD_TYPE=release

BUILD_ID=KRT16S

OUT_DIR=out

============================================

 

 

编译好后,进入模拟器

http://jingyan.baidu.com/article/86112f13549b44273797872c.html

 

source build/envsetup.sh

lunch

1

emulator



大功告成~ 现在可以随心所欲的学习源码了~


你可能感兴趣的:(ubuntu 14.10 编译 android 4.4kitkat)