Android源码编译出错解决办法

编译环境:Ubuntu12.04 64位

Android源码:Android 4.3

 以下问题是笔者亲自碰到,通过网上查询整合在一起的。

1.error while loading shared libraries: libz.so.1: cannot open shared object file:No such file or directory

这里所说不能加载libz.so.1这个包,所以需要下载,笔者使用了几种方法,以下是自己使用过,测试是OK的.

我们使用命令apt-get search 安装

apt-get install apt-file

在安装完后提示你使用apt-file update输入命名

apt-file 是用来查找某个命令或者某一个库所在的包的,具体用法如下

root@ubuntu:/home/zhenghui# apt-file search libz.so.1

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

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

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

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

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

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

这里我们发现已经找到了libz.so.1所以安装对应的包,执行命令

apt-get install lib32z1

 

2.“mkimage” command not found - U-Boot images will not be built

从网上说使用apt-get install uboot-mkimage 但是笔者没有得到解决,可能是使用的环境不一样,提示是:

root@ubuntu:/home/zhenghui# apt-get install uboot-mkimage

Reading package lists... Done

Building dependency tree

Reading state information... Done

Package uboot-mkimage is not available, but is referred to by another package.

This may mean that the package is missing, has been obsoleted, or

is only available from another source

However the following packages replace it:

  u-boot-tools:i386 u-boot-tools

 

E: Package 'uboot-mkimage' has no installation candidate

这里说下载两个u-boot-tools:i386 和u-boot-tools两个工具,这里就安装两个工具。

 

3.fatal error: zlib.h: No such file or directory

没有zlib.h这个文件,使用命令安装

apt-get install zlib1g-dev

 

4.gperf not found

解决方法:安装gperf

apt-get install gperf

 

5./usr/bin/ld: cannot find  -lncurses

解决方法:安装libncurses5-dev:i386则可以搞定

apt-get install libncurses5-dev:i386

 

6.fatal error: uuid/uuid.h: No such file or directory

这个是因为没有安装uuid软件开发包的原因,使用一下命令解决:

sudo apt-get install uuid-dev

在安装完了之后,可能需要做一个软链接 命令:

ln -sf /lib/i386-linux-gnu/libuuid.so.1 /usr/lib/libuuid.so

 

7.Can't locate Switch.pm in @INC

解决方法是安装perl的switch库,安装命令:

apt-get install libswitch-perl

 

8./bin/bash: xmllint: command not found

解决方法安装 xmllint 命令如下:

apt-get install libxml2-utils

 

9.make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/noproguard.classes-with-local.dex] Killed

网上说内存不足,采用一下方法得到解决,增大交换分区的大小,这里就分了1G给交换分区:

在根目录创建swap文件夹:

mkdir swap

cd swap

sudo dd if=/dev/zero of=swapfile bs=1024 count=1048576

sudo mkswap swapfile //把生成的文件转换成 Swap 文件

sudo swapon swapfile //激活 Swap 文件

如果需要卸载。执行命令:swapoff swapfile

 

Andorid编译成功后,会在/out/target/product/sabresd_6dq下生成三个img:recovery.img 、system.img、 boot.img和u-boot.bin

 

原文地址:https://www.cnblogs.com/zalebool/p/4517525.html