android源码的编译问题总结

来源:互联网 发布:服务器开源软件 编辑:程序博客网 时间:2024/05/16 08:13

由于目前的项目需要修改android的内核源码,所以我需要从android源码的编译开始学习.

下面看一下我的编译环境.
我使用的Ubuntu系统的版本是14.04,64位.
gcc版本:4.8.8

编译过程我是看着google开发者官网,以及结合别人的博客进行编译的.编译的过程会遇到很多问题,在这里,我就把我遇到的问题总结一些,以便以后用到的时候容易查看,也方便别人编译android的时候遇到相同的问题,便于查看.

问题一:java版本问题
这里写图片描述

这个问题描述的是我当前使用的java版本是”1.7”,而正确的版本是java se 1.6,所以我们需要更换java.

解决办法:

1:使用命令(因为我使用的是openjdk)

sudo apt-get remove openjdk-7-jre openjdk-7-jdk openjdk-7-jre-headless

2:如果你使用的是JDK,为了以后还会使用,先讲全局变量中的export语句使用’#’注释掉即可.

3:安装Java SE 1.6
4:从官网下载并且解压之后,配置环境变量即可

问题二:编译问题

这里写图片描述

解决方法:

1:找到android源代码/frameworks/base/tools/aapt/Android.mk文件,编辑

找到第31行的LOCAL_CFLAGS,后面添加-fpermissive

这里写图片描述

2:找到android源代码frameworks/base/libs/utils/Android.mk文件,编辑
找到第64行的LOCAL_CFLAGS,后面添加-fpermissive

这里写图片描述

问题三:

这里写图片描述

解决办法:

cd external/srecwget "https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff"patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diffrm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diffcd ../..

问题四:

这里写图片描述

这个问题仅仅需要将dalvik/vm/native/dalvik_system_Zygote.cpp中添加一句”#include

#include <getopt.h>

问题六:

这里写图片描述

解决办法:
在文件development/tools/emulator/opengl/Android.mk中的第25行后面添加 -fpermissive

这里写图片描述

错误七:

这里写图片描述

解决办法:

在文件/development/tools/emulator/opengl/host/renderer/Android.mk文件中的LOCAL_CFLAGS += -O0 -g的下一行添加"LOCAL_LDLIBS += -lX11"

LOCAL_PATH:=$(call my-dir)# host renderer process ###########################$(call emugl-begin-host-executable,emulator_renderer)$(call emugl-import,libOpenglRender)LOCAL_SRC_FILES := main.cppLOCAL_CFLAGS    += -O0 -gLOCAL_LDLIBS += -lX11#ifeq ($(HOST_OS),windows)#LOCAL_LDLIBS += -lws2_32#endif$(call emugl-end-module)

错误八:

这里写图片描述

解决办法:

将文件build/core/combo/HOST_linux-x86.mk中的
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
替换为
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

错误八:
这里写图片描述

解决办法:

将文件中frameworks/compile/slang/Android.mk第22行中的-werror移除

这里写图片描述

错误九:
这里写图片描述

解决办法:
在文件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>

错误十:

这里写图片描述

解决办法:

安装perl switch库

sudo apt-get install libswitch-perl

错误十一:

external/oprofile/libpp/format_output.h:94:22: 错误: reference ‘counts’ cannot be declared ‘muta
external/oprofile/libpp/format_output.h:94:22: 错误: reference ‘counts’ cannot be declared ‘muta…
针对这种情况,需要修改external/oprofile/libpp/format_output.h:94行
mutable counts_t & counts为
counts_t & counts

错误十二:

这里写图片描述

解决办法:

修改文件external/llvm/llvm-host-build.mk
中添加 LOCAL_LDLIBS := -lpthread -ldl

错误十三:

external/gtest/src/../include/gtest/gtest-param-test.h:1185:28: required from here
external/gtest/src/../include/gtest/internal/gtest-param-util-generated.h:77:26: error: ‘ValuesIn’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
return ValuesIn(array);

解决办法:

将文件/external/gtest/src/Android.mk中所有的”LOCAL_CFLAGS += -O0”修改为”LOCAL_CFLAGS += -O0 -fpermissive”

错误十四:
make: *
[out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1

解决方法:

gedit external/gtest/include/gtest/internal/gtest-param-util.h 添加:

#include <cstddef>
1 0
原创粉丝点击