首页 > 代码库 > 在Ubuntu14.04上编译Android4.0.1出现的几个问题

在Ubuntu14.04上编译Android4.0.1出现的几个问题

一. 工具

     sudo apt-get install git-core gnupg flex bison gperf build-essential \

      zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \

      libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \

      libgl1-mesa-dev g++-multilib mingw32 tofrodos \

      python-markdown libxml2-utils xsltproc zlib1g-dev:i386

 

二.JDK 

     oracle 官网下载JDk6_29(bin文件,注意安装方法,环境变量,update-alternative等)   http://www.oracle.com/technetwork/java/javase/archive-139210.html

 

三.gcc/g++的版本

 默认的gcc g++版本为4.6.3,  将其改为4.4.步骤:

 sudo apt-get install gcc-4.4
 sudo apt-get install g++-4.4
 cd /usr/bin
 ls -l gcc*
 sudo mv gcc gcc.bak
 sudo ln -s gcc-4.4 gcc
 ls -l g++*
 sudo mv g++ g++.bak
 sudo ln -s g++-4.4 g++
 gcc -v
 g++ -v

四.源的问题

 

  很多repo不能用,这个一般都可以: curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ~/bin/repo
  另外。init的时候用这个: repo init -u git://git.omapzoom.org/platform/manifest -b android-4.0.1_r1
  之后 repo sync出现“fatal: ‘../platform/abi/cpp.git‘ does not appear to be a git repository”的解决方案,则打开.repo目录下的manifest.xml文件(命令vim manifest.xml)并找到fetch属性,在我的文件中显示fetch="..",将fetch修改为 fetch="git://git.omapzoom.org"
 
五 .同步后出现的问题
 
1. 出错以下出错信息:
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. Import includes file: out/target/product/mx3/obj/STATIC_LIBRARIES/libwebcore_intermediates/import_includes  
  2. target Generated: libwebcore <= external/webkit/Source/WebCore/css/tokenizer.flex  
  3. <span style="rgb(255, 255, 51);">Can‘t locate Switch.pm in @INC (you may need to install the Switch module)</span> (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23.  
  4. BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.  
  5. Can‘t locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23.  
  6. BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.  
  7. make: *** [out/target/product/mx3/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/html/DocTypeStrings.cpp] Error 2  
  8. make: *** Waiting for unfinished jobs....  
  9. make: *** [out/target/product/mx3/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/platform/ColorData.cpp] Error 2  
  10. target Generated: libwebcore <= external/webkit/Source/WebCore/html/parser/HTMLEntityNames.in  

解决方法是安装perl的switch库:
[plain] view plaincopy在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install libswitch-perl 

     

 

2.dalvik/vm/native/dalvik_system_Zygote.cpp:216:43: error: ‘setrlimit’ was not declared in this scope
err = setrlimit(contents[0], &rlim);
^
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]
dalvik/vm/native/java_lang_Float.cpp:1:0: note: this is the location of the previous definition
/*
^
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o] Error 1
make: *** Waiting for unfinished jobs....

解决办法
添加头文件#include <sys/resource.h>到以下文件
dalvik/vm/native/dalvik_system_Zygote.cpp

\

 

3.host Executable: emulator_renderer (out/host/linux-x86/obj/EXECUTABLES/emulator_renderer_intermediates/emulator_renderer)
/usr/bin/ld: out/host/linux-x86/obj/EXECUTABLES/emulator_renderer_intermediates/main.o: undefined reference to symbol ‘XInitThreads‘
//usr/lib/i386-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_renderer_intermediates/emulator_renderer] Error 1
make: *** Waiting for unfinished jobs....


解决办法:
修改development/tools/emulator/opengl/host/renderer/Android.mk文件
root@ubuntu:/home/dzt/android/WORKING_DIRECTORY# ls
abi cts docs frameworks Makefile prebuilt
bionic dalvik download.sh hardware ndk sdk
bootable development download.sh~ hs_err_pid6190.log out system
build device external libcore packages v8.log
root@ubuntu:/home/dzt/android/WORKING_DIRECTORY# gedit development/tools/emulator/opengl/host/renderer/Android.mk

添加一行:LOCAL_LDLIBS += -lX11 注意最好是复制过去,右边的容易写错

\

 

在Ubuntu14.04上编译Android4.0.1出现的几个问题