现在的位置: 首页 > 综合 > 正文

Ubuntu 12.04编译android 4.0.4 SDK错误解决

2013年08月13日 ⁄ 综合 ⁄ 共 7165字 ⁄ 字号 评论关闭

编译源码前更新所需要的库:

Installing required packages (Ubuntu 12.04)
You will need a 64-bit version of Ubuntu. Ubuntu 12.04 is recommended. Building using an older version of Ubuntu is not supported on master or recent releases.

$ sudo apt-get install git 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
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

一.

out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o): In function `PrintStackTrace':
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Unix/Signals.inc:219: undefined reference to `dladdr'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Unix/Signals.inc:231: undefined reference to `dladdr'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), 

void*, unsigned int)':
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Threading.cpp:96: undefined reference to `pthread_create'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Threading.cpp:91: undefined reference to `pthread_attr_setstacksize'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Threading.cpp:100: undefined reference to `pthread_join'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()':
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock'
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `MutexImpl':
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Mutex.cpp:69: undefined reference to `pthread_mutexattr_init'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Mutex.cpp:75: undefined reference to `pthread_mutexattr_settype'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Mutex.cpp:80: undefined reference to `pthread_mutexattr_setpshared'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Mutex.cpp:89: undefined reference to `pthread_mutexattr_destroy'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Mutex.cpp:69: undefined reference to `pthread_mutexattr_init'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Mutex.cpp:75: undefined reference to `pthread_mutexattr_settype'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Mutex.cpp:80: undefined reference to `pthread_mutexattr_setpshared'
/home/cuijinquan/android-src/android4.0/external/llvm/lib/Support/Mutex.cpp:89: undefined reference to `pthread_mutexattr_destroy'
collect2: ld returned 1 exit status
target R.java/Manifest.java: AccelerometerPlay (out/target/common/obj/APPS/AccelerometerPlay_intermediates/src/R.stamp)
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1


解决:
 
Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux 

修改external/llvm/llvm-host-build.mk 
LOCAL_IS_HOST_MODULE := true
后添加:
LOCAL_LDLIBS := -lpthread -ldl

二.

host C++: a3dconvert <= development/tools/a3dconvert/ColladaGeometry.cpp
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]
<built-in>:0:0: note: this is the location of the previous definition
host C++: a3dconvert <= development/tools/a3dconvert/ColladaLoader.cpp
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by default]
<built-in>:0:0: note: this is the location of the previous definition
In file included from development/tools/a3dconvert/ColladaLoader.h:28:0,
                 from development/tools/a3dconvert/ColladaLoader.cpp:17:
development/tools/a3dconvert/GeometryLoader.h:31:8: warning: extra tokens at end of #endif directive [enabled by default]
host C++: libRS <= frameworks/base/libs/rs/rsAdapter.cpp
host C++: libRS <= frameworks/base/libs/rs/rsAllocation.cpp
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>:0:0: note: this is the location of the previous definition
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
cc1plus: all warnings being treated as errors
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libRS_intermediates/rsAdapter.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libRS_intermediates/rsAllocation.o] Error 1

解决:

修改build/core/combo/HOST_linux-x86.mk61行,将

HOST_GLOBAL_CFLAGS+= -D_FORTIFY_SOURCE=0

修改成

HOST_GLOBAL_CFLAGS+= -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

三.

frameworks/compile/slang/slang_rs_export_foreach.cpp: In static member function ‘static slang::RSExportForEach* slang::RSExportForEach::Create(slang::RSContext*, 

const clang::FunctionDecl*)’:
frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
 vi frameworks/compile/slang/Android.mk  

解决:

      在打开的makefile文件中按照下面更改:
       
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror
       
修改成local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-paramete,

      就是删除后面的警告错误提示 -Werror

四.

   Package SDK: out/host/linux-x86/sdk/android-sdk_eng.root_linux-x86.zip
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: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.root_linux-x86.zip] Error 44

解决:

     在out/host/linux-x86/framework 搜索文件名去掉-tests的相同jar文件,如ddmlib.jar,找到后,把文件copy到out/host/linux-x86/framework目录下,修改文件名加
上-tests,如ddmlib-tests.jar.

  pc-bios/bios.bin其实是在prebuilt/common/下面,修改文件sdk/build/tools.atree内对应出错的行

  GpsLocationTest.apk,ConnectivityTest.apk文件我没去找了,应该也能找到,找到后修改路径或复制到对应路径下就行了.

      我直接用make PRODUCT-sdk-sdk来解决这两个apk,如果直接make sdk会报找不到这两个apk

   网上的解决方法是:

   1.source build/envsetup.sh

    2.lunch sdk-eng

    3.make sdk

   但我测试来,还是报一样的错,解决不了我的问题.

五.

  external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: 错误: ‘ptrdiff_t’不是一个类型名
In file included from external/gtest/src/../include/gtest/gtest-param-test.h:157:0,
                 from external/gtest/src/../include/gtest/gtest.h:69,
                 from external/gtest/src/../src/gtest.cc:34,
                 from external/gtest/src/gtest-all.cc:36:

解决方法:
      $vim external/gtest/src/../include/gtest/internal/gtest-param-util.h

     添加:
            #include <cstddef>

六编译完成后,运行android命令提示:

       /out/host/linux-x86/framework/x86_64' does not exist.

     1,  find ./|grep swt.jar

      2.找到后修改: export ANDROID_SWT=~/android-src/android4.0/out/host/linux-x86/sdk/android-sdk_eng.cuijinquan_linux-x86/tools/lib/x86_64

     3.同步更新:source ~/.bashrc

 七.无法更新平台:

    修改

  更新平台:
     修改/etc/hosts文件,添加:
          74.125.237.1 dl-ssl.google.com

     source /etc/hosts

   八.搞定.

抱歉!评论已关闭.