博客:http://blog.csdn.net/muyang_ren
Ubuntu14.04 LTS(要求是64位长期支持版LTS)
Jdk1.8
内核:android4.0
一:jdk
1、解压jdk,获得路径
2、
sudo vim /etc/environment
修改为:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/lhy/jdk/jdk1.8.0_45/bin" JAVA_HOME="/home/lhy/jdk/jdk1.8.0_45" CLASSPATH=".:/home/lhy/jdk/jdk1.8.0_45/lib"
3、source /etc/environment
二:ubuntu配置
需要注意jdk的版本和编译器gcc、g++的版本问题,
官网配置:http://source.android.com/source/initializing.html
Ubuntu14.04:
sudo apt-get install bison g++-multilib git gperf libxml2-utils make python-networkx zlib1g-dev:i386 zip 把下面出现错误需要安装的都放在这了 sudo apt-get install gcc-4.4-multilib sudo apt-get install g++-4.4-multilib sudo apt-get install flex sudo apt-get install libncurses5-dev sudo apt-get install lib32ncurses5-dev sudo apt-get install libswitch-perl sudo apt-get install u-boot-tools sudo apt-get install gawk(这个是网上看到需要装的,我就提前安装就没出错了)
出现错误:
下列软件包有未满足的依赖关系: g++-multilib : 依赖: gcc-multilib (>= 4:4.8.2-1ubuntu6) 但是它将不会被安装 依赖: g++ (>= 4:4.8.2-1ubuntu6) 但是它将不会被安装 E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系
处理方法:
sudo apt-get install g++ sudo apt-get install gcc-multilib
出现错误:
Checking build tools versions... ************************************************************ You are attempting to build with the incorrect version of java. Your version is: java version "1.8.0_45". The correct version is: Java SE 1.6. Please follow the machine setup instructions at http://source.android.com/source/download.html ************************************************************ build/core/main.mk:131: *** stop。 停止。
解决办法,
使用jdk 1.6 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/lhy/jdk/jdk1.6.0_29/bin" JAVA_HOME="/home/lhy/jdk/jdk1.6.0_29" CLASSPATH=".:/home/lhy/jdk/jdk1.6.0_29/lib"
出现错误:
g++: selected multilib '32' not installed make: *** [out/host/linux-x86/obj/EXECUTABLES/aapt_intermediates/aapt] 错误 1
解决办法:
需要安装gcc、g++的multilib包,直接执行下面的命令,会自动安装g++、gcc的multilib包; sudo apt-get install g++-4.4-multilib
出现错误(这个其实可以忽略):
注意:某些输入文件使用或覆盖了已过时的 API。 注意:要了解详细信息,请使用 -Xlint:deprecation 重新编译。 注意:某些输入文件使用了未经检查或不安全的操作。 注意:要了解详细信息,请使用 -Xlint:unchecked 重新编译。
解决办法(手敲,别tab键,机不好会卡好久):make update-api
出现错误:
/bin/bash: flex: command not found make: *** [out/host/linux-x86/obj/EXECUTABLES/aidl_intermediates/aidl_language_l.cpp] Error 127
解决办法:
sudo apt-get install flex
出现错误:
host C: adb <= system/core/adb/transport_usb.c host C: adb <= system/core/adb/commandline.c host C: adb <= system/core/adb/adb_client.c host C: adb <= system/core/adb/sockets.c host C: adb <= system/core/adb/services.c host C: adb <= system/core/adb/file_sync_client.c host C: adb <= system/core/adb/get_my_path_linux.c host C: adb <= system/core/adb/usb_linux.c host C: adb <= system/core/adb/utils.c host C: adb <= system/core/adb/usb_vendors.c host C: adb <= system/core/adb/fdevent.c 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] 错误 1
解决办法:
sudo apt-get install libncurses5-dev
发现错误:
/usr/bin/ld: cannot find -lncurses collect2: ld returned 1 exit status make: *** [out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb] 错误 1
解决办法:
sudo apt-get install lib32ncurses5-dev
发现错误:
dalvik/vm/native/dalvik_system_Zygote.cpp: In function ‘int setrlimitsFromArray(ArrayObject*)’: dalvik/vm/native/dalvik_system_Zygote.cpp:194: error: aggregate ‘rlimit rlim’ has incomplete type and cannot be defined dalvik/vm/native/dalvik_system_Zygote.cpp:217: error: ‘setrlimit’ was not declared in this scope make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libdvm_intermediates/native/dalvik_system_Zygote.o] 错误 1
解决办法:
$ vim dalvik/vm/native/dalvik_system_Zygote.cpp 添加头文件 #include <sys/resource.h>
发现错误:
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. BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23.
解决办法:
sudo apt-get install libswitch-perl
出现错误:
/bin/bash: mkimage: 未找到命令 make: *** [out/target/product/fs210/ramdisk.img] 错误 127 make: *** 正在删除文件“out/target/product/fs210/ramdisk.img”
解决办法:
sudo apt-get install uboot-mkimage **如果出现以下提示** --------------------------------------------------------- 现在没有可用的软件包 uboot-mkimage,但是它被其它的软件包引用了。 这可能意味着这个缺失的软件包可能已被废弃, 或者只能在其他发布源中找到 可是下列软件包取代了它: u-boot-tools:i386 u-boot-tools E: 软件包 uboot-mkimage 没有可供安装的候选者 --------------------------------------------------------- **就安装以下工具** sudo apt-get install u-boot-tools
发现错误:
frameworks/base/include/utils/KeyedVector.h: In instantiation of ‘const VALUE& android::DefaultKeyedVector<KEY, VALUE>::valueFor(const KEY&) const [with KEY = android::String8; VALUE = android::wp<android::AssetManager::SharedZip>]’: frameworks/base/libs/utils/AssetManager.cpp:1797:44: required from here 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] ssize_t i = indexOfKey(key); ^ 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] 错误 1
解决办法:
更换gcc和g++的版本 1.lhy@Ubuntu-14:~$ cd /usr/bin/ 2.查看gcc和g++文件 lhy@Ubuntu-14:/usr/bin$ ls -l gcc* lrwxrwxrwx 1 root root 7 6月 30 18:38 gcc -> gcc-4.8 -rwxr-xr-x 1 root root 255080 3月 20 2014 gcc-4.4 -rwxr-xr-x 1 root root 775888 5月 15 02:54 gcc-4.8 lrwxrwxrwx 1 root root 10 6月 30 18:38 gcc-ar -> gcc-ar-4.8 -rwxr-xr-x 1 root root 26968 5月 15 02:54 gcc-ar-4.8 lrwxrwxrwx 1 root root 10 6月 30 18:38 gcc-nm -> gcc-nm-4.8 -rwxr-xr-x 1 root root 26968 5月 15 02:54 gcc-nm-4.8 lrwxrwxrwx 1 root root 14 6月 30 18:38 gcc-ranlib -> gcc-ranlib-4.8 -rwxr-xr-x 1 root root 26968 5月 15 02:54 gcc-ranlib-4.8 lhy@Ubuntu-14:/usr/bin$ ls -l g++* lrwxrwxrwx 1 root root 7 4月 8 2014 g++ -> g++-4.8 -rwxr-xr-x 1 root root 259176 3月 20 2014 g++-4.4 -rwxr-xr-x 1 root root 775888 5月 15 02:40 g++-4.8 3.将之前的备份: lhy@Ubuntu-14:/usr/bin$ sudo mv gcc gcc.bak lhy@Ubuntu-14:/usr/bin$ sudo mv g++ g++.bak 4.创建新的gcc和g++链接 lhy@Ubuntu-14:/usr/bin$ sudo ln -s gcc-4.4 gcc lhy@Ubuntu-14:/usr/bin$ sudo ln -s g++-4.4 g++ 5.查看gcc和g++版本 lhy@Ubuntu-14:/usr/bin$ gcc -v lhy@Ubuntu-14:/usr/bin$ g++ -v
出现以下内容,编译成功
mkimage -A arm -O linux -T ramdisk -C none -a 0x30A00000 -n "ramdisk" -d out/target/product/fs210/ramdisk.img out/target/product/fs210/ramdisk-uboot.img Image Name: ramdisk Created: Mon Jun 29 03:49:56 2015 Image Type: ARM Linux RAMDisk Image (uncompressed) Data Size: 165454 Bytes = 161.58 kB = 0.16 MB Load Address: 30a00000 Entry Point: 30a00000 Target userdata fs image: out/target/product/fs210/userdata.img in mkuserimg.sh PATH=out/host/linux-x86/bin/:/home/lhy/jdk/jdk1.6.0_29/bin:/usr/local/sbin:/us r/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/ local/games:/home/lhy/jdk/jdk1.6.0_29/bin:/home/lhy/src_21 0/android4.0-fs210_v2/out/host/linux-x86/bin:/home/lhy/src_210/android4.0- fs210_v2/prebuilt/linux-x86/toolchain/arm-linux- androideabi-4.4.x/bin:/home/lhy/src_210/android4.0- fs210_v2/development/emulator/qtools:/home/lhy/src_210/and roid4.0-fs210_v2/prebuilt/linux-x86/toolchain/arm-linux- androideabi-4.4.x/bin:/home/lhy/src_210/android4.0- fs210_v2/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin make_ext4fs -s -l 536870912 -a data out/target/product/fs210/userdata.img out/target/product/fs210/data Creating filesystem with parameters: Size: 536870912 Block size: 4096 Blocks per group: 32768 Inodes per group: 8192 Inode size: 256 Journal blocks: 2048 Label: Blocks: 131072 Block groups: 4 Reserved block group size: 31 Created filesystem with 20/32768 inodes and 4234/131072 blocks out/target/product/fs210/userdata.img total size is 10797456
<p>版权声明:本文为博主原创文章,未经博主允许不得转载。</p>