ubuntu 1404 AMD64 下载编译Android4.0
安装
1
2
3
4
5
6
7
8 mkdir ~/bin
PATH=~/bin:$PATH
cd ~/bin
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
chmod +x repo
# 配置repo更新,使用tuna镜像源更新,将下面内容复制到~/.bashrc里
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
source ~/.bashrc
- 安装JDK1.6参考
下载:https://www.oracle.com/java/technologies/javase-java-archive-javase6-downloads.html ,我下的是:jdk-6u45-linux-x64.bin,将它复制到/usr/java,改为可执行,执行安装,添加到PATH环境,具体操作如下:
mkdir /usr/java
cp ~/Downloads/jdk-6u45-linux-x64.bin /usr/java
cd /usr/java
chmod +x jdk-6u45-linux-x64.bin
./jdk-6u45-linux-x64.bin
sudo rm -rf jdk-6u45-linux-x64.bin
#配置环境
sudo vim ~/.bashrc
export ANDROID_JAVA_HOME=’/usr/java/jdk1.6.0_45’
export PATH=”$ANDROID_JAVA_HOME/bin:$PATH”
export CLASSPATH=”$ANDROID_JAVA_HOME/lib/dt.jar:$ANDROID_JAVA_HOME/lib/tools.jar”source ~/.bashrc
同步源码
mkdir AndroidResource
cd AndroidResource
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-4.0.1_r1
repo sync
编译源码(过程会有一些错,在文章的最底部)
source build/envsetup.sh
./build/envsetup.sh
m
编译SDK(过程会有一些错,在文章的最底部)
m sdk
运行
设置环境变量
export PATH=”
/AndroidResource/out/host/linux-x86/bin:$PATH”/AndroidResource/out/target/product/generic
export ANDROID_PRODUCT_OUT=
其中*
/AndroidResource/out/host/linux-x86/bin中有emulator指令,/AndroidResource/out/target/product/generic*有Android镜像将编译的Android镜像运行到emulator上
emulator-arm //或 emulator
编译Android源码遇到的错误
- error: sys/cdefs.h: No such file or directory
sudo apt-get install libc6-dev-i386
在安装JDK6之后,还是找不到jdk6
打开/build/core/find-jdk-tools-jar.sh可以发现,缺少$ANDROID_JAVA_HOME,把~/.bashrc 中的JAVA_HOME改成ANDROID_JAVA_HOME
修改权限存放Android源码的目录:sudo chmod 755 -R ~/AndroidResource/
not found bits/c++config.h,参考
sudo apt-get install gcc-4.8-multilib g++-4.8-multilib
[out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] Error 1
在*/frameworks/base/tools/aapt/Android.mk* 第31行处改为
LOCAL_CFLAGS += -Wno-format-y2k -fpermissive
[out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetManager.o] Error 1
在/frameworks/base/libs/utils/Android.mk 第64行 改为
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
[out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile.o] Error 1
patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
cd ../..
[out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o] Error 1
- 添加 #include <sys/resource.h> 到 dalvik/vm/native/dalvik_system_Zygote.cpp 中
[out/host/linux-x86/obj/EXECUTABLES/emugen_intermediates/main.o] Error 1
- 在 development/tools/emulator/opengl/host/tools/emugen/main.cpp 中添加 #include <getopt.h>
[out/host/linux-x86/obj/STATIC_LIBRARIES/libOpenglCodecCommon_intermediates/GLSharedGroup.o] Error 1
在 development/tools/emulator/opengl/Android.mk 第25行 改为
EMUGL_COMMON_CFLAGS := -DWITH_GLES2 -fpermissive
[out/host/linux-x86/obj/lib/libOpenglRender.so] Error 1
sudo apt-get install libx11-dev:i386
[out/host/linux-x86/obj/EXECUTABLES/emulator_renderer_intermediates/emulator_renderer] Error 1
- 在 development/tools/emulator/opengl/host/renderer/Android.mk 新增一行 LOCAL_LDLIBS += -lX11,如下:
1
2
3LOCAL_SRC_FILES := main.cpp
LOCAL_CFLAGS += -O0 -g
LOCAL_LDLIBS += -lX11/usr/include/zlib.h:34:19: fatal error: zconf.h: No such file or directory -> #include “zconf.h”
- 在usr/include中没有找到zconf.h,由于zlib1g-dev的路径改变,才找不到。解决办法:将新路径的zconf.h拷贝到usr/include目录下,如下:
sudo cp /usr/include/x86_64-linux-gnu/zconf.h /usr/include/
[out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1
将*/build/core/combo/HOST_linux-x86.mk* 中的 HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 修改为
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
[out/host/linux-x86/obj/lib/libGLES_CM_translator.so] Error 1
如果在/usr/lib/i386-linux-gnu/中没有发现mesa文件夹,安装(参考)
sudo apt-get install libc6:i386
sudo apt-get install libgl1-mesa-glx-lts-trusty:i386有的话,执行(libGL.so.1查看自己的版本)
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/libGL.so
[out/host/linux-x86/obj/EXECUTABLES/llvm-rs-cc_intermediates/slang_rs.o] Error 1
- 将frameworks/compile/slang/Android.mk第21行local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter注释掉
[out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMJIT_intermediates/Intercept.o] Error 1
在external/llvm/lib/ExecutionEngine/JIT/Intercept.cpp中添加
#define _LARGEFILE64_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
[out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/html/DocTypeStrings.cpp] Error 2
sudo apt-get install libswitch-perl
[out/host/linux-x86/obj/STATIC_LIBRARIES/libRS_intermediates/rsFont.o] Error 1
- 在frameworks/base/libs/rs/Android.mk 中第183行后面添加-fpermissive例如:LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-variable -fpermissive*
- [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1
- 在external/oprofile/libpp/format_output.h中第94行,将mutable移除 ,改为counts_t & counts;
- [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1
- 在*external/llvm/llvm-host-build.mk*中添加
> LOCAL_LDLIBS := -lpthread -ldl
[out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1
1)在external/gtest/src/Android.mk的52行和70行添加*-fpermissive*
LOCAL_CFLAGS += -O0 -fpermissive
2)在external/gtest/include/gtest/internal/gtest-param-util.h中添加几个头文件
#include
#include
#include <gtest/internal/gtest-port.h>
编译SDK遇到的错误
development/build/sdk.atree:229: couldn't locate source file: framework/layoutlib-tests.jar development/build/sdk.atree:230: couldn't locate source file: system/app/ConnectivityTest.apk development/build/sdk.atree:231: couldn't locate source file: system/app/GpsLocationTest.apk sdk/build/tools.atree:47: couldn't locate source file: usr/share/pc-bios/bios.bin sdk/build/tools.atree:48: couldn't locate source file: usr/share/pc-bios/vgabios-cirrus.bin sdk/build/tools.atree:146: couldn't locate source file: framework/ddmlib-tests.jar sdk/build/tools.atree:147: couldn't locate source file: framework/ninepatch-tests.jar sdk/build/tools.atree:148: couldn't locate source file: framework/common-tests.jar sdk/build/tools.atree:150: couldn't locate source file: framework/sdkuilib-tests.jar make: *** [out/host/linux-x86/sdk/android-sdk_eng.d_linux-x86.zip] Error 44
1)类似XXX-tests.jar的问题,通过在*AndroidSRC/out/host/linux-x86/framework/*,中ddmlib.jar复制一份名为ddmlib-tests.jar。
2)运行lunch sdk-eng 再执行m sdk