首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Ubuntu11.10(32位)编译android常见异常

2012-06-30 
Ubuntu11.10(32位)编译android常见错误开始正式编译,在源码目录下make即可。make我完全不知道跑了个啥,只知

Ubuntu11.10(32位)编译android常见错误

开始正式编译,在源码目录下make即可。

make

我完全不知道跑了个啥,只知道超级卡。完成后产生的out文件夹有3.9G。

镜像生成在out/target/product/generic下:android源码编译后得到system.img,ramdisk.img,userdata.img映像文件。其中, ramdisk.img是emulator的文件系统,system.img包括了主要的包、库等文件,userdata.img包括了一些用户数据,emulator加载这3个映像文件后,会把 system和 userdata分别加载到 ramdisk文件系统中的system和 userdata目录下。

当然编译是件很痛苦的事情:

错误1:

************************************************************

You are attempting to build on a 32-bit system.

Only 64-bit build environments are supported beyond froyo/2.2.

************************************************************

解决:

需要进行如下修改即可,将

./external/clearsilver/cgi/Android.mk

./external/clearsilver/java-jni/Android.mk

./external/clearsilver/util/Android.mk

./external/clearsilver/cs/Android.mk

四个文件中的

LOCAL_CFLAGS += -m64

LOCAL_LDFLAGS += -m64

注释掉,或者将“64”换成“32”

LOCAL_CFLAGS += -m32

LOCAL_LDFLAGS += -m32

然后,将./build/core/main.mk 中的

ifneq (64,$(findstring 64,$(build_arch)))

改为:

ifneq (i686,$(findstring i686,$(build_arch)))

错误2:

host C++: libutils <= frameworks/base/libs/utils/RefBase.cpp

frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:

frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1

解决:

gedit frameworks/base/libs/utils/Android.mk

Change the line:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

To:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive

错误3:

 

host Executable: aapt (out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt)

out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_get':

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:27: undefined reference to `pthread_getspecific'

out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_set':

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:36: undefined reference to `pthread_key_create'

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:44: undefined reference to `pthread_setspecific'

collect2: ld returned 1 exit status

make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] 错误 1

解决:

打开 frameworks/base/tools/aapt/Android.mk

然后打开文件Android.mk,编辑下面一行:

ifeq ($(HOST_OS),linux)

#LOCAL_LDLIBS += -lrt       把这行注释掉,改为下面一行。

LOCAL_LDLIBS += -lrt -lpthread

endif

错误4:

target Dex: core

#

# An unexpected error has been detected by HotSpot Virtual Machine:

#

#  SIGSEGV (0xb) at pc=0x4003d848, pid=7668, tid=2889534320

#

# Java VM: Java HotSpot(TM) Client VM (1.5.0_22-b03 mixed mode)

# Problematic frame:

# C  [libpthread.so.0+0xa848]  pthread_cond_timedwait+0x168

#

# An error report file with more information is saved as hs_err_pid7668.log

#

# If you would like to submit a bug report, please visit:

#   http://java.sun.com/webapps/bugreport/crash.jsp

#

make: *** [out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.dex] 已放弃 (core dumped)

解决:

虚拟机给的内存512太小,给个1G试试。然后在本机里打开任务管理器,找到虚拟机进程,优先级设置为实时。给他最多东西。

错误 5:

out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_get':

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:27: undefined reference to `pthread_getspecific'

out/host/linux-x86/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a(threads.o): In function `thread_store_set':

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:36: undefined reference to `pthread_key_create'

/home/leno/works/android_dev/bin/system/core/libcutils/threads.c:44: undefined reference to `pthread_setspecific'

collect2: ld returned 1 exit status

make: *** [out/host/linux-x86/obj/EXECUTABLES/localize_intermediates/localize] 错误 1

解决:类似问题3

修改./framework/base/tools/localize/Android.mk文件

ifeq ($(HOST_OS),linux)

#LOCAL_LDLIBS += -lrt       把这行注释掉,改为下面一行。

LOCAL_LDLIBS += -lrt -lpthread

endif


错误1:

注意:external/protobuf/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java 使用了未经检查或不安全的操作。

注意:要了解详细信息,请使用 -Xlint:unchecked 重新编译。
注意:external/protobuf/java/src/main/java/com/google/protobuf/micro/CodedInputStreamMicro.java 使用了未经检查或不安全的操作。
注意:要了解详细信息,请使用 -Xlint:unchecked 重新编译。
Generated: (out/target/product/generic/android-info.txt)
host C: acp <= build/tools/acp/acp.c
host C++: libhost <= build/libs/host/pseudolocalize.cpp
host C: libhost <= build/libs/host/CopyFile.c
<命令行>:0:0: 警告: “_FORTIFY_SOURCE”重定义 [默认启用]
<built-in>:0:0: 附注: 这是先前定义的位置
<命令行>:0:0: 警告: “_FORTIFY_SOURCE”重定义 [默认启用]
<built-in>:0:0: 附注: 这是先前定义的位置
In file included from build/libs/host/CopyFile.c:11:0:
build/libs/host/include/host/CopyFile.h:5:22: 致命错误: sys/stat.h:没有那个文件或目录
编译中断。
In file included from /usr/include/stdlib.h:25:0,
                 from build/tools/acp/acp.c:11:
/usr/include/features.h:323:26: 致命错误: bits/predefs.h:没有那个文件或目录
编译中断。
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/CopyFile.o] 错误 1
make: *** 正在等待未完成的任务....
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] 错误 1
<命令行>:0:0: 警告: “_FORTIFY_SOURCE”重定义 [默认启用]
<built-in>:0:0: 附注: 这是先前定义的位置
In file included from /usr/include/c++/4.6/x86_64-linux-gnu/32/bits/os_defines.h:40:0,
                 from /usr/include/c++/4.6/x86_64-linux-gnu/32/bits/c++config.h:392,
                 from /usr/include/c++/4.6/string:40,
                 from build/libs/host/include/host/pseudolocalize.h:4,
                 from build/libs/host/pseudolocalize.cpp:1:
/usr/include/features.h:323:26: 致命错误: bits/predefs.h:没有那个文件或目录
编译中断。

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o] 错误 1


注意:某些输入文件使用或覆盖了已过时的 API。
注意:要了解详细信息,请使用 -Xlint:deprecation 重新编译。
注意:某些输入文件使用了未经检查或不安全的操作。

注意:要了解详细信息,请使用 -Xlint:unchecked 重新编译。

解决方法:sudo apt-get install libc6-dev-i386

http://www.blogjava.net/ZircoN/archive/2011/11/13/363452.html

错误2:

frameworks/base/libs/utils/RefBase.cpp: 在成员函数‘void android::RefBase::weakref_type::trackMe(bool, bool)’中:
frameworks/base/libs/utils/RefBase.cpp:483:67: 错误: 将‘const android::RefBase::weakref_impl’作为‘void android::RefBase::weakref_impl::trackMe(bool, bool)’的‘this’实参时丢弃了类型限定 [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1
make: *** 正在等待未完成的任务....
frameworks/base/libs/utils/ResourceTypes.cpp: 在成员函数‘void android::ResTable::print(bool) const’中:
frameworks/base/libs/utils/ResourceTypes.cpp:4369:84: 警告: 将一个整数转换为大小不同的指针 [-Wint-to-pointer-cast]

frameworks/base/libs/utils/ResourceTypes.cpp:4375:43: 警告: 将一个整数转换为大小不同的指针 [-Wint-to-pointer-cast]

参考网上的解决方法:

$ gedit frameworks/base/libs/utils/Android.mk

将下面一行

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

改成

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive

http://www.blogjava.net/ZircoN/archive/2011/11/13/363452.html

问题并没有解决,反而又出现了新的错误:

host C++: libutils <= frameworks/base/libs/utils/Asset.cpp
g++: –fpermissive:没有那个文件或目录
注意:某些输入文件使用或覆盖了已过时的 API。
注意:要了解详细信息,请使用 -Xlint:deprecation 重新编译。
注意:某些输入文件使用了未经检查或不安全的操作。
注意:要了解详细信息,请使用 -Xlint:unchecked 重新编译。
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/Asset.o] 错误 1
make: *** 正在删除文件“out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/Asset.o”

make: *** 正在等待未完成的任务....

这个错误主要是gcc版本过高引起的:最终解决办法是:

(11.10的gcc版本过高

http://hi.baidu.com/designhouse/blog/item/fec5cdbf8d6a231618d81fc1.html)

ubuntu 11.10的gcc版本是4.6.1,版本太高,编译android时出错,要把gcc版本改为4.4.3。

通过gcc -v命令可以发现gcc库在/usr/lib/gcc/i686-linux-gnu目录下,该目录下有当前系统支持的各种版本gcc库 。在安装gcc 4.4前该目录下是没有4.4目录的,安装gcc 4.4后该目录下就会多出4.4这个目录,且该4.4目录下有各种相应库文件。

ubuntu 32bit系统下安装gcc 4.4的最好方法是仅用以下两条命令,不需要其它命令,否则编译时可能会出错。

sudo apt-get install gcc-4.4

sudo apt-get install g++-4.4



装完后在/usr/bin目录下

$ ls -l gcc*

lrwxrwxrwx 1 root root      7 2011-10-29 09:11 gcc -> gcc-4.6

-rwxr-xr-x 1 root root 224544 2011-10-06 05:47 gcc-4.4

-rwxr-xr-x 1 root root 302104 2011-09-17 05:43 gcc-4.6

发现gcc 链接到gcc-4.6,  需要将它改为链接到gcc-4.4 :

sudo mv gcc gcc.bak

sudo ln -s gcc-4.4 gcc

$ls -l g++*

sudo -s

mv g++-4.4 g++

g++ -v



错误3:

g++: g++: selected multilib '32' not installed
selected multilib '32' not installed
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl] 错误 1
make: *** 正在等待未完成的任务....
make: *** [out/host/linux-x86/obj/lib/libESR_Portable.so] 错误 1

解决方法:

输入:sudo apt-get install gcc-multilib

sudo apt-get install g++-multilib后出现新问题:


g++: g++: host SharedLib: libfst (out/host/linux-x86/obj/lib/libfst.so)
g++: selected multilib '32' not installedselected multilib '32' not installed

selected multilib '32' not installed
make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl] 错误 1
make: *** 正在等待未完成的任务....
make: *** [out/host/linux-x86/obj/lib/libESR_Portable.so] 错误 1

make: *** [out/host/linux-x86/obj/lib/libfst.so] 错误 1

解决方法


 sudo apt-get install libc6-dev ia32-libs lib32ncurses5-dev x11proto-core-dev libx11-dev lib32readline-gplv2-dev lib32z-dev libgl1-mesa-dev mingw32 tofrodos python-markdown libxml2-utils

sudo apt-get install g++-4.4-multilib

错误4:



Could not load 'clearsilver-jni'
java.library.path = out/host/linux-x86/lib
Could not load 'clearsilver-jni'
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/api-stubs-timestamp] 错误 45
make: *** 正在等待未完成的任务....
make: *** [out/target/common/docs/doc-comment-check-timestamp] 错误 45

解决方法:

这是由于clearsilver 在编译时如果检测到使用Java JDK 6,就使用64位编译。要避开此错误,需要修改下面四个文件:

* external/clearsilver/cgi/Android.mk
* external/clearsilver/java-jni/Android.mk
* external/clearsilver/util/Android.mk
* external/clearsilver/cs/Android.mk

把这四个Makefile中的下列语句注掉即可:

# This forces a 64-bit build for Java6
# Comment by Easwy
# LOCAL_CFLAGS += -m64
# LOCAL_LDFLAGS += -m64

然后在external/clearsilver目录中执行一下make clean,然后回到项目根目录,继续make即可。

当编译完成时,生成的image文件放在out/target/product/generic目录中。


gedit /root/.bashrc
export PATH=/root/android/mydroid/out/host/linux-x86/bin:$PATH
export ANDROID_PRODUCT_OUT=/root/android/mydroid/out/target/product/generic
export ANDROID_SWT=/root/android/mydroid/out/host/linux-x86/framework

在源码目录下的out/target/product/generic/目录下运行
emulator -image system.img -data userdata.img -ramdisk ramdisk.img 命令

错误5:

 emulator

NAND: could not write file system.img, File exists


热点排行