zoukankan      html  css  js  c++  java
  • 64位Ubuntu Kylin14下编译安卓2.3.3过程记录

    由于国内的网络环境,上google成为一件蛋疼的事,就单单一个2.3版本的源代码就下载了好几天,当然前提除了hosts文件外没用其他任何工具,hosts时不时需要更新才能正常的访问google,编译过程中报了很多错,基本上前人都遇到过,只要有耐心去查,google和baidu交叉使用,基本都能找到解决方法,其中最蛋疼的应是Ubuntu版本,经历了这么一次后,个人觉得编译安卓Ubuntu版本应该选择安卓对应版本当时的Ubuntu版本,否则会有一些意想不到的问题

    上google的方法

    google-hosts

    源码的获取参考下面两个链接

    google源码获取官方示例

    源码获取 指定-b 分支可下载对应版本的源码


    Ubuntu14 环境初始化

    Installing required packages (Ubuntu 14.04)
    Building on Ubuntu 14.04 is experimental at the moment but will eventually become the recommended environment.
    $ sudo apt-get install bison g++-multilib git gperf libxml2-utils
    


    遇到的错误及解决方法,部分错误未记录

    [1]
    Your version is: java version "1.6.0_24".
    The correct version is: Java SE 1.6.
    1.设置jdk环境变量
    编译android源码只支持jdk 1.6,所以如果需要编译源码必须下载jdk 1.6,不能下载最新的jdk 1.7,如果不需要编译源码则可以下载1.7版本的。
    1.6版本jdk下载地址:http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html
    不要把环境变量配置在/etc/environment和/etc/profile文件中,这样配置的在有的ubuntu版本上会出现退出当前终端后不起作用的问题,在ubuntu12.04上我就遇到了此问题。
    把环境变量配置在用户目录.bashrc文件中是最好的选择。
    export JAVA_HOME=/home/abc/jdk1.6.0_45
    export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
    export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
    然后执行source .bashrc使配置生效即可。
    
    [2]/usr/include/features.h:356:25: 致命错误: sys/cdefs.h:没有那个文件或目录
    To compile 32 bit binaries on 64 bit Linux version, you have to Install libx32gcc development package and 32 bit GNU C Library
    try this
    sudo apt-get install libx32gcc-4.8-dev
    sudo apt-get install libc6-dev-i386
    
    [3]致命错误: zlib.h:没有那个文件或目录
    下面这个错误是因为zlib包没有安装,安装后问题即可解决。但有一点请注意安装命令是:sudo apt-get install zlib1g-dev,而非sudo apt-get install zlib
    ./file_util.cpp:19:18: 致命错误: zlib.h:没有那个文件或目录
    编译中断。
    sudo apt-get install zlib1g-dev
    
    [4]一个问题是有一处少了一个头文件,原因是zlib1g-dev有个头文件修改了路径,及zconf.h放到了/usr/include/x86_64-linux-gnu/,所以将其拷贝到/usr/include/下即可了
    In file included from system/extras/ext4_utils/output_file.c:30:
    /usr/include/zlib.h:34: fatal error: zconf.h: 没有那个文件或目录
    compilation terminated.
    
    [5] Error:
    frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<android::String8, android::sp<AaptDir> >’ are not found by unqualified lookup
    frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
    make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/AaptAssets.o] Error 1
    Fix:
    vi frameworks/base/tools/aapt/Android.mk
    Add '-fpermissive' to line 31:
    LOCAL_CFLAGS += -Wno-format-y2k -fpermissive
    
    [6] Error:
    frameworks/base/include/utils/KeyedVector.h:193:31: error: ‘indexOfKey’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
    frameworks/base/include/utils/KeyedVector.h:193:31: note: declarations in dependent base ‘android::KeyedVector<android::String8, android::wp<android::AssetManager::SharedZip> >’ are not found by unqualified lookup
    frameworks/base/include/utils/KeyedVector.h:193:31: note: use ‘this->indexOfKey’ instead
    make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/AssetManager.o] Error 1
    Fix:
    vi frameworks/base/libs/utils/Android.mk
    Add '-fpermissive' to line 64:
    LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive
    
    
    [7] Error:
    external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:136:11: note: use ‘this->SetState’ instead
    make: *** [out/host/linux-x86/obj/EXECUTABLES/grxmlcompile_intermediates/grxmlcompile.o] Error 1
    Fix:
    cd external/srec
    wget "https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff"
    patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
    rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
    cd ../..
    
    
    [8] /usr/bin/ld: cannot find -lncurses
    host Executable: adb (out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb)
    /usr/bin/ld: cannot find -lncurses
    collect2: ld returned 1 exit status
    make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] Error 1
    解决方法:
    sudo apt-get install libncurses5-dev(32位系统)
    sudo apt-get install lib32ncurses5-dev(64位系统)
    
    
    [9] 错误1:out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o
    解决方法:
    vim dalvik/vm/native/dalvik_system_Zygote.c 
    #include "Dalvik.h"
    #include "native/InternalNativePriv.h"
    下面加上一行:
    #include <sys/resource.h>
    
    [10]
    make: *** [out/host/linux-x86/obj/EXECUTABLES/mksnapshot_intermediates/src/accessors.o] 
    错误 1
    Fix:
    gcc g++版本过高,应该都降级为4.4才行
    版本切换见http://www.linuxidc.com/Linux/2012-10/72284.htm
    如果源里没有gcc4.4,则切换到163的源
    $sudo apt-get install gcc-4.4
    $sudo apt-get install gcc-4.4-multilib
    $sudo apt-get install g++-4.4
    $sudo apt-get install g++-4.4-multilib
    
    $sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40
    $sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60
    $sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 40
    $sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 60
    $sudo update-alternatives --config gcc
    $sudo update-alternatives --config g++
      Selection    Path              Priority   Status
    ------------------------------------------------------------
    * 0            /usr/bin/g++-4.6   60        auto mode
      1            /usr/bin/g++-4.4   40        manual mode
      2            /usr/bin/g++-4.6   60        manual mode
    选择1.
    如果想改为高版本的随时用update-alternatives --config 命令切换!
    修改后第一次编译仍然存在错误,第二次编译就没有错误了,具体原因我也不清楚。
    [11] out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/HTMLNames.h
    Fix:sudo apt-get install libswitch-perl 
    




  • 相关阅读:
    sqlhelper使用指南
    大三学长带我学习JAVA。作业1. 第1讲.Java.SE入门、JDK的下载与安装、第一个Java程序、Java程序的编译与执行 大三学长带我学习JAVA。作业1.
    pku1201 Intervals
    hdu 1364 king
    pku 3268 Silver Cow Party
    pku 3169 Layout
    hdu 2680 Choose the best route
    hdu 2983
    pku 1716 Integer Intervals
    pku 2387 Til the Cows Come Home
  • 原文地址:https://www.cnblogs.com/lizhangqu/p/4234563.html
Copyright © 2011-2022 走看看