基本编译配置:

ubuntu 13 / android 4.0 SDK / eclips / gcc 4.4 / g++ 4.4 / jdk1.6.0_27

首先,确认你的各个工具包是否安装正确,而需要安装正确,首先要确认你的update list是不是最新而且完备。

你需要用apt-get update 来确认一下你的安装源是不是完备,如果没得到done的结果基本上你就是没做对,后面你就会遇到各种各样因为缺失库而出现的各种古怪问题。

ubuntu 的右上角有一个Updates Available……

先在这里面选一个中国的源,

【hsy75】

注意,不要选择更新整个系统,而是选择“Setting”。然后,选择other/.china下的东西。

#apt-get update

如果,一直更新失败,也许是原来的源冲突了,需要做下面几步:

ubuntu apt-get update失败
1.出现错误:E:Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
出现这个问题的原因可能是有另外一个程序正在运行,导致资源被锁不可用。而导致资源被锁的原因,可能是上次安装时没正常完成,而导致出现此状况。
 
解决方法:把 /var/lib/apt/lists 中的文件全部删掉
输入以下命令
sudo rm /var/cache/apt/archives/lock
 
sudo rm /var/lib/dpkg/lock
 
之后再安装想装的包,即可解决
2.出现错误:E: Some index files failed to download. They have been ignored, or old ones used instead.
解决方法:
To upgrade a really old Ubuntu release, we first need to edit our sources.
list and change all(xx.)archive.ubuntu.com to old-releases.ubuntu.com.
 
   $ sudo emacs /etc/apt/sources.list
So your lines should instead of
   deb http://archive.ubuntu.com/ubuntu jaunty main restricted universe
look like
   deb http://old-releases.ubuntu.com/ubuntu jaunty main restricted universe
In this example I use jaunty release. But it works the same on other releases.
Now update the repos  
   $ sudo apt-get update

1  缺少库的编译错误

dalvik/vm/native/dalvik_system_Zygote.cpp:222:43: error: ‘setrlimit’ was not declared in this scopeerr = setrlimit(contents[0], &rlim);

解决办法:

add #include <sys/resource.h> to dalvik/vm/native/dalvik_system_Zygote.cpp

详细参考:

http://mjanja.co.ke/2013/04/fix-for-dalvik-compile-error-on-cyanogenmod-9/

2 makefile 路径的问题

因为makefile 大概一般找的都/usb/bin /usr/lib

2.1 ubuntu 缺少统一的路径配置,或者由于多个不同的包没有配置,所以编译系统找不到:

如何你把他搞成绝对或者相对的路径,那你会面对另外一个问题,那就是你编译系统可以顺利找到东西,可是ubuntu系统则搞不定了。。。

所以最好最有效的方法,还是利用ubuntu提供的工具来解决,只是设定优先级,然后,系统会主动觉得该用哪个,那个不好用(API)就换一个

这里举例javadoc,其他还有java,javac,javah,gcc,g++等类似这种配置

实际问题如下:

Docs droiddoc: out/target/common/docs/doc-comment-check
Docs droiddoc: out/target/common/docs/api-stubs
host layoutlib_create: out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar
-rw-r--r-- 1 root root 9240987  4月  4 00:30 out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar
/bin/bash: line 2: javadoc: command not found
/bin/bash: line 2: javadoc: command not found
make: *** [out/target/common/docs/api-stubs-timestamp] Error 45
make: *** Waiting for unfinished jobs....
make: *** [out/target/common/docs/doc-comment-check-timestamp] Error 45

解决办法:

sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.6.0_27/bin/javadoc 300

其他的配置举例:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_27/bin/java 300

sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_27/bin/javac 300

sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.6.0_27/bin/jar  300

然后通过

sudoupdate-alternatives --config java

命令检查 java 的配置

hsy@ubuntu:/usr/lib/jvm/jdk1.6.0_27/bin$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                           Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      manual mode
  2            /usr/lib/jvm/jdk1.6.0_27/bin/java               300       manual mode

原来的选择是openjdk

Press enter to keep the current choice[*], or type selection number:
输入我们刚才的配置的2 选项,把系统默认java设为这个

hsy@ubuntu:/usr/lib/jvm/jdk1.6.0_27/bin$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection    Path                                           Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      auto mode
  1            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1071      manual mode
* 2            /usr/lib/jvm/jdk1.6.0_27/bin/java               300       manual mode

接下来是有关gcc ,g++的设定,和上节类似;

hsy@ubuntu:/usr/lib/jvm/jdk1.6.0_27/bin$ sudo update-alternatives --config gcc
sudoupdate-alternatives: command not found

说明gcc 还没配置,据说android 应该用 gcc 4.4

看看 我们有没有hsy@ubuntu:/usr/bin$ ls -all *gcc*
-rwxr-xr-x 1 root root    428 May  7  2006 c89-gcc
-rwxr-xr-x 1 root root    454 Apr 11  2011 c99-gcc
lrwxrwxrwx 1 root root      7 Feb 13 06:43 gcc -> gcc-4.7
-rwxr-xr-x 1 root root 527596 Apr 15  2013 gcc-4.7
-rwxr-xr-x 1 root root  22000 Apr 15  2013 gcc-ar-4.7
-rwxr-xr-x 1 root root  22000 Apr 15  2013 gcc-nm-4.7
-rwxr-xr-x 1 root root  22000 Apr 15  2013 gcc-ranlib-4.7
装吧

hsy@ubuntu:/usr/bin$ sudo apt-get install gcc-4.4

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
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4  40
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7  60

hsy@ubuntu:/usr/bin$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-4.7   60        auto mode
  1            /usr/bin/gcc-4.4   40        manual mode
  2            /usr/bin/gcc-4.7   60        manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/gcc-4.4 to provide /usr/bin/gcc (gcc) in manual mode

hsy@ubuntu:/usr/bin$ ls -all g++*
lrwxrwxrwx 1 root root     21 Apr  6 19:30 g++ -> /etc/alternatives/g++
-rwxr-xr-x 1 root root 224576 Jan 30  2013 g++-4.4
-rwxr-xr-x 1 root root 527596 Apr 15  2013 g++-4.7

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.7  60

hsy@ubuntu:/usr/bin$ sudo update-alternatives --config g++
There are 2 choices for the alternative g++ (providing /usr/bin/g++).

Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/g++-4.7   60        auto mode
  1            /usr/bin/g++-4.4   40        manual mode
  2            /usr/bin/g++-4.7   60        manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/g++-4.4 to provide /usr/bin/g++ (g++) in manual mode

至此编译需要的各种编译包已经完成自动选择配置

至于很多人说的要修改 /etc/profile 或者 /etc/enviroment 之类

这个也许有效,但是非常麻烦,还有考虑各个配置的作用域,很难理解!

笔者经过试验完全没有必要 可以正常编译生成正常的文件。

3 虚拟机内存设定导致的编译问题

编译android遇到java虚拟机堆内存不够的问题

问题一:

UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:269)
    at com.android.dx.command.dexer.Main.run(Main.java:240)
    at com.android.dx.command.dexer.Main.main(Main.java:174)
    at com.android.dx.command.Main.main(Main.java:95)
make: *** [out/target/common/obj/JAVA_LIBRARIES/core_intermediates/noproguard.classes-with-local.dex] Error 3
make: *** Deleting file `out/target/common/obj/JAVA_LIBRARIES/core_intermediates/noproguard.classes-with-local.dex'
make: *** Waiting for unfinished jobs....
true
true

问题二:

target Dex: framework
make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/noproguard.classes-with-local.dex] Killed

解决办法:

修改definitions.mk文件 此文件位于build/core/目录下

修改变量 :transform-classes.jar-to-dex中的-JXms16M -JXmx1024M

ref:

--http://blog.csdn.net/ydt_lwj/article/details/8468272

4使用Android的DX工具编译Class文件出现no classfiles specified问题

target Dex: core
Copy: apicheck (out/host/linux-x86/obj/EXECUTABLES/apicheck_intermediates/apicheck)
Install: out/target/product/x210/system/lib/libc.so
target SharedLib: libstdc++ (out/target/product/x210/obj/SHARED_LIBRARIES/libstdc++_intermediates/LINKED/libstdc++.so)
error: no command specified
usage:
  dx --dex [--debug] [--verbose] [--positions=<style>] [--no-locals]
  [--no-optimize] [--statistics] [--[no-]optimize-list=<file>] [--no-strict]
  [--keep-classes] [--output=<file>] [--dump-to=<file>] [--dump-width=<n>]
  [--dump-method=<name>[*]] [--verbose-dump] [--no-files] [--core-library]
  [--num-threads=<n>]
  [<file>.class | <file>.{zip,jar,apk} | <directory>] ...
    Convert a set of classfiles into a dex file, optionally embedded in a
    jar/zip. Output name must end with one of: .dex .jar .zip .apk. Positions
    options: none, important, lines.
  dx --annotool --annotation=<class> [--element=<element types>]
  [--print=<print types>]
  dx --dump [--debug] [--strict] [--bytes] [--optimize]
  [--basic-blocks | --rop-blocks | --ssa-blocks | --dot] [--ssa-step=<step>]
  [--width=<n>] [<file>.class | <file>.txt] ...
    Dump classfiles, or transformations thereof, in a human-oriented format.
  dx --junit [-wait] <TestClass>
    Run the indicated unit test.
  dx --find-usages <file.dex> <declaring type> <member>
    Find references and declarations to a field or method.
    declaring type: a class name in internal form, like Ljava/lang/Object;
    member: a field or method name, like hashCode
  dx -J<option> ... <arguments, in one of the above forms>
    Pass VM-specific options to the virtual machine that runs dx.
  dx --version
    Print the version of this tool (1.7).
  dx --help
    Print this message.
make: *** [out/target/common/obj/JAVA_LIBRARIES/core_intermediates/noproguard.classes-with-local.dex] Error 1
make: *** Waiting for unfinished jobs....
target SharedLib: libm (out/target/product/x210/obj/SHARED_LIBRARIES/libm_intermediates/LINKED/libm.so)

此问题没有解决,可能是和虚拟机的配置有关,例如
VT技术

但是也许是小节6描述的那样,也可能是虚拟机的内存过小,或者不够用造成的。

解决的办法看小结6

5 java相关问题

5.1

hsy@ubuntu:~/x210/x210_ics_rtm_v13$ sudo ./mk -s
build/core/config.mk:268: *** Error: could not find jdk tools.jar, please install JDK6, which you can download from java.sun.com.  Stop.

6 虚拟机的内存不足导致的编译问题

有各种各样的报错表现,例如小结4描述的错误

6.1 绝大多数报错包含如下信息:

make: *** Waiting for unfinished jobs....

6.2 也有报错说是

g++ bug 需要提交的,其实也是内存不够用导致的未知错误

解决的办法很简单:增加内存。如果没有的话,也可以解决

那就是重新启动vmware 虚拟机,然后再编译一次,这样前面的内存占用会被释放出来

然后,你会再出现一个非常诡异的错误,然后地方和上次不同,

重新启动vm,再继续,再来,直到编译结束。

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]

【修改的地方可能有以下这些】

1

解决办法:  frameworks/base/tools/aapt/Android.mk
       在第31行增加:
       LOCAL_CFLAGS += -Wno-format-y2k -fpermissive

2

解决办法:在 development/tools/emulator/opengl/Android.mk
    增加  '-fpermissive' 到25行:
       EMUGL_COMMON_CFLAGS := -DWITH_GLES2 -fpermissive

3

Fix:
vi frameworks/base/libs/utils/Android.mk

Add '-fpermissive' to line 64:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

4

vi frameworks/base/libs/rs/Android.mk

Add '-fpermissive' to line 183
LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-unused-variable -fpermissive

external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:132:9: note: declarations in dependent base ‘fst::VectorFstBaseImpl<fst::CacheState<fst::GallicArc<fst::StdArc, (fst::StringType)0u> > >’ are not found by unqualified lookup
external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:132:9: note: use ‘this->SetState’ instead
external/srec/tools/thirdparty/OpenFst/fst/lib/cache.h:136:11: error: ‘SetState’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]

【hsy75案:步骤1

sudo wget "https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff"

【记录】

--2014-12-17 20:26:55--  https://github.com/CyanogenMod/android_external_srec/commit/4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff
Resolving github.com (github.com)... 192.30.252.130
Connecting to github.com (github.com)|192.30.252.130|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff’

[  <=>                   ] 13,142      48.8KB/s   in 0.3s

2014-12-17 20:26:57 (48.8 KB/s) - ‘4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff’ saved [13142]

hsy75案:步骤2】

hsy@ubuntu:~/x210_ics_rtm_v13/external/srec$ sudo patch -p1 < 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff

【记录】

patching file tools/thirdparty/OpenFst/fst/lib/cache.h
patching file tools/thirdparty/OpenFst/fst/lib/compose.h
patching file tools/thirdparty/OpenFst/fst/lib/const-fst.h
patching file tools/thirdparty/OpenFst/fst/lib/determinize.h
patching file tools/thirdparty/OpenFst/fst/lib/factor-weight.h
patching file tools/thirdparty/OpenFst/fst/lib/map.h
patching file tools/thirdparty/OpenFst/fst/lib/vector-fst.h

【hsy75案:步骤3】

hsy@ubuntu:~/x210_ics_rtm_v13/external/srec$ sudo rm -f 4d7ae7b79eda47e489669fbbe1f91ec501d42fb2.diff

[内存不足】

android arm-linux-androideabi-gcc: Internal error: Killed (program cc1)

arm-linux-androideabi-g++: Internal error: Killed (program cc1plus)

【解决】加大内存设置,或者在编一次

dalvik/vm/native/dalvik_system_Zygote.cpp: In function ‘int setrlimitsFromArray(ArrayObject*)’:
dalvik/vm/native/dalvik_system_Zygote.cpp:194:19: error: aggregate ‘setrlimitsFromArray(ArrayObject*)::rlimit rlim’ has incomplete type and cannot be defined
dalvik/vm/native/dalvik_system_Zygote.cpp:217:43: error: ‘setrlimit’ was not declared in this scope
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o] Error 1

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]

Two fixes required:
1)
vi external/gtest/src/Android.mk

Add '-fpermissive' to lines 52 and 70 (both lines contain same info)
LOCAL_CFLAGS += -O0 -fpermissive

2)
vi external/gtest/include/gtest/internal/gtest-param-util.h

Add '#include <stddef.h>' to list of includes as shown:
#include <vector>
#include <cstddef>
#include <gtest/internal/gtest-port.h>

1 编译Android Source时碰到的问题

http://blog.csdn.net/zaizaishan/article/details/8950707

2 Android编译问题总结

http://blog.csdn.net/yyhzpk/article/details/7078385

3 Ubuntu安装Sun JDK及如何设置默认java JDK

http://blog.sina.com.cn/s/blog_437ff56b0100tfi5.html

any discusstion?

QQ:QQ 1624673069

【环境搭建005】UBUNTU13.04 android4.08 源码编译实践中遇到的问题相关推荐

  1. 干货|TensorFlow开发环境搭建(Ubuntu16.04+GPU+TensorFlow源码编译)

    点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 本文转自|机器学习算法工程师 安装平台 1 平台 目前Tensor ...

  2. anaconda tensorflow 2.3_TensorFlow开发环境搭建(Ubuntu16.04+GPU+TensorFlow源码编译)

    1 安装选择 1.1 平台 目前TensorFlow已支持Mac.Ubuntu和Windows三个主流平台(64位平台), 1.2 GPU vs CPU 在安装时可以选择安装版本是否支持GPU, 1. ...

  3. Unix NetWork Programming——环境搭建(解决unp.h等源码编译问题)(转载)

    原文地址:http://blog.csdn.net/a649518776/article/details/6724121 下面开始用简单但典型的客户端和服务器端程序说明如何进行网络编程.这一小节讲的是 ...

  4. Android4.0源码编译方法以及错误解决方案

    from:http://blog.csdn.net/wanjun8659/article/details/8095664 历时一个星期,终于将android4.0源码编译成功,中间经历了各种曲折,非常 ...

  5. Android4.4源码编译(Ubuntu1204/1404)

    好久没写博客了,最近折腾了一个周,总算把Android4.4系统源码编译通过,有网上的大神们在,其实也不难. 效果图 一.介绍 我的电脑配置不咋滴(i3+4G+320),分了90个G来装了个Ubunt ...

  6. WSL Ubuntu 20.04下Android源码编译与导入Android Studio

    源码下载见前文:WSL Ubuntu 20.04下Android源码下载 idegen 模块编译 在development/tools/idegen/README下可以看到关于 idegen 工具的相 ...

  7. 源码编译Ros, Ubuntu18.04系统使用源码编译Ros1,出错集合及其解决办法

    官方的介绍http://wiki.ros.org/kinetic/Installation中提到了,脚本安装的方法it is available for Ubuntu Wily (15.10) and ...

  8. 5单个编译总会编译全部_玩转Android10(五)源码编译开发中常用命令

    源码开发编译中,熟练掌握常用命令,可以提高开发工作效率.Android源码中,将相关的命令分为如下几类: 1.初始化源码编译环境 初始化编译环境,为后续提供如lunch.make.xxgrep.god ...

  9. Android8.1源码编译实践(Mac)

    第0步:版本选择 AOSP版本选择很重要,如果选错了,会造成编译失败等各种问题,编译AOSP对Xcode的版本是有要求的: 比如:AOSP6.0-7.0,要求Xcode的版本是8.3,然而在MacOS ...

最新文章

  1. JVM运行时数据区---堆(堆内存)
  2. iview 表单 验证_iview必备技能一、表单验证规则
  3. uchome 模板引擎
  4. 薪资留人还是情感留人?
  5. JPA 一对一设置无效,连表查询的时候另外一个实体类的对象值为空
  6. iqueryable怎么进行操作_钢结构施工要点有哪些?怎么进行操作?
  7. 字节输出流写入数据到文件
  8. 探索App保活黑科技
  9. vivado 2017.4安装教程
  10. Ubuntu双系统、ROS、软件安装教程
  11. 前端基础—HTML制作课程表
  12. word回车后间距太大_Word调整字号间距 Word回车换行间距变大
  13. Seek the Name, Seek the Fame POJ - 2752(KMP和hah两种方法求公共前后缀)
  14. Vue-cli的安装与基本操作
  15. 【老九】【Java】随机数详解
  16. Rxjava--背压(Backpressure)
  17. Java毕业设计-流浪动物救助系统
  18. 快速完成网页设计,10个顶尖响应式HTML5网页模板助你一臂之力
  19. 美国贝勒大学计算机科学专业怎么样,贝勒大学专业排名一览(含历年专业排名信息,USNEWS美国大学排名版)...
  20. 微信分享报错errMsg: “updateAppMessageShareData:fail, the permission value is offline verifying“

热门文章

  1. Node.js_1.1
  2. 【kubernetes / k8s 踩坑记录】一定要关闭SWAP
  3. 02326 操作系统 简答题 超简短归纳
  4. java TCP 从客户端键入信息 循环接收发送 示例
  5. Tensorflow MNIST 手写识别
  6. python ctypes
  7. react 组件引用组件_自定位React组件
  8. 黑客马拉松 招募_举办第一次黑客马拉松的提示
  9. wordpress忘记登录密码,更改域名的办法。
  10. java zip压缩_压缩工具