- 浏览: 24009 次
- 性别:
- 来自: 南京
最近访客 更多访客>>
最新评论
-
guolong2008:
不错呀,学习了
Android 源码修改 -
lenomon:
dengbin50 写道谢谢,在你的帮助下我解决了问题!那多多 ...
Android 模拟器接受UDP/TCP数据报 -
dengbin50:
谢谢,在你的帮助下我解决了问题!
Android 模拟器接受UDP/TCP数据报 -
lenomon:
这篇文章比较详细 PC电脑和Android模拟器访问及模拟器之 ...
Android 模拟器接受UDP/TCP数据报
How to build android 2.3 source code
- 博客分类:
- Android
转载:http://easwy.com/blog/archives/compile-android-gingerbread-2-3-1/
前几天下载了Android 2.3.1的源代码并在Ubuntu 10.04(32位)上编译通过。这篇文章简要记录了下载、编译的过程。
关于搭建Android开发环境的文章已经有很多,本文只简要介绍一下,做为备忘。
[ 编译前的准备 ]
这一步安装获取源代码以及编译所需要的软件,使用如下命令:
$ sudo aptitude install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
另外,参考别人编译Android 2.3的经验,安装了下列软件包:
$ sudo apt-get install lib64z1-dev libc6-dev-amd64 g++-multilib lib64stdc++6
虽然Android官方网站上讲不支持Java 6,不过我使用Java 6也可以编译通过,所以在这里Easwy安装的是Java 6。首先去掉/etc/apt/sources.list中这两行的注释,使能Java 6源:
deb http://archive.canonical.com/ubuntu lucid partner
deb-src http://archive.canonical.com/ubuntu lucid partner
然后安装Java 6 JDK:
$ sudo aptitude install sun-java6-jdk
接下来下载repo工具,这是Google提供的一个Python脚本,方便管理多个Git版本库:
$ cd ~
$ mkdir bin
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
记得把repo加到你的路径中,方便以后使用。编辑~/.bashrc,加入下面一行:
PATH=$PATH:~/bin
export PATH
然后用命令. ~/.bashrc,以后就可以直接使用repo命令了。
接下来获取Android 2.3.1的源代码:
$ mkdir mydroid
$ cd mydroid
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-2.3.1_r1
$ repo sync
[ 编译Android ]
接下来开始编译:
$ make -j`grep '^processor' /proc/cpuinfo | wc -l`
上面的命令中,-j参数告诉make启动多个并行任务进行编译,在支持多核的CPU上能加快编译速度。如果你知道你CPU是几核的,可以直接把这部分替换成-j2(双核)。
我在编译的过程中遇到下面的错误:
************************************************************
You are attempting to build on a 32-bit system.
Only 64-bit build environments are supported beyond froyo/2.2.
************************************************************
这是因为在Makefile中检测了CPU的字长。我直接把build/core/main.mk中下面的话注释掉:
#ifneq (64,$(findstring 64,$(build_arch)))
#$(warning ************************************************************)
#$(warning You are attempting to build on a 32-bit system.)
#$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
#$(warning ************************************************************)
#$(error stop)
#endif
接下来又遇到下面的错误:
Docs droiddoc: out/target/common/docs/api-stubs
Could not load ‘clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/api-stubs-timestamp] Error 45
make: *** Waiting for unfinished jobs….
Could not load ‘clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/doc-comment-check-timestamp] Error 45
这是由于clearsilver在编译时如果检测到使用Java JDK 6,就使用64位编译。要避开此错误,需要修改下面四个文件:
* external/clearsilver/cgi/Android.mk
* external/clearsilver/java-jni/Android.mk
* external/clearsilver/util/Android.mk
* external/clearsilver/cs/Android.mk
把这四个Makefile中的下列语句注掉即可:
# This forces a 64-bit build for Java6
# Comment by Easwy
# LOCAL_CFLAGS += -m64
# LOCAL_LDFLAGS += -m64
然后在external/clearsilver目录中执行一下make clean,然后回到项目根目录,继续make即可。
当编译完成时,生成的image文件放在out/target/product/generic目录中。
常见问题:
1:issue "You are attempting to build on a 32-bit system"
How to fix:
$ vim build/core/main.mk
change
ifneq (64,$(findstring 64,$(build_arch)))
to
ifneq (i686,$(findstring i686,$(build_arch)))
$(warning ************************************************************)
$(warning You are attempting to build on a 32-bit system.)
$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
$(warning ************************************************************)
$(error stop)
endif
external/clearsilver/cgi/Android.mk,
external/clearsilver/java-jni/Android.mk,
external/clearsilver/util/Android.mk,
external/clearsilver/cs/Android.mk
change
LOCAL_CFLAGS += -m64
LOCAL_LDFLAGS += -m64
to
LOCAL_CFLAGS += -m32
LOCAL_LDFLAGS += -m32
2:issue "host C: libclearsilver-jni <= external/clearsilver/java-jni/j_neo_util.c
In file included from /usr/include/features.h:378,
from /usr/include/string.h:26,
from external/clearsilver/java-jni/j_neo_util.c:1:
/usr/include/gnu/stubs.h:9:27: error: gnu/stubs-64.h: 没有那个文件或目录
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libclearsilver- jni_intermediates/j_neo_util.o]错误"
How to fix:
sudo apt-get install lib64z1-dev libc6-dev-amd64 g++-multilib lib64stdc++6
3:issue:
host SharedLib: libneo_util (out/host/linux-x86/obj/lib/libneo_util.so)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libneo_util.so] Error 1
How to fix:
4
frameworks/base/core/java/android/app/ListActivity.java:319: inconvertible types
found : android.widget.AdapterView<capture of ?>
required: android.widget.ListView
onListItemClick((ListView)parent, v, position, id);
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
How to fix:
其实JDK的版本低了,用了 1.5.0_06的版本,用1.6就可以了
前几天下载了Android 2.3.1的源代码并在Ubuntu 10.04(32位)上编译通过。这篇文章简要记录了下载、编译的过程。
关于搭建Android开发环境的文章已经有很多,本文只简要介绍一下,做为备忘。
[ 编译前的准备 ]
这一步安装获取源代码以及编译所需要的软件,使用如下命令:
$ sudo aptitude install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev
另外,参考别人编译Android 2.3的经验,安装了下列软件包:
$ sudo apt-get install lib64z1-dev libc6-dev-amd64 g++-multilib lib64stdc++6
虽然Android官方网站上讲不支持Java 6,不过我使用Java 6也可以编译通过,所以在这里Easwy安装的是Java 6。首先去掉/etc/apt/sources.list中这两行的注释,使能Java 6源:
deb http://archive.canonical.com/ubuntu lucid partner
deb-src http://archive.canonical.com/ubuntu lucid partner
然后安装Java 6 JDK:
$ sudo aptitude install sun-java6-jdk
接下来下载repo工具,这是Google提供的一个Python脚本,方便管理多个Git版本库:
$ cd ~
$ mkdir bin
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
记得把repo加到你的路径中,方便以后使用。编辑~/.bashrc,加入下面一行:
PATH=$PATH:~/bin
export PATH
然后用命令. ~/.bashrc,以后就可以直接使用repo命令了。
接下来获取Android 2.3.1的源代码:
$ mkdir mydroid
$ cd mydroid
$ repo init -u git://android.git.kernel.org/platform/manifest.git -b android-2.3.1_r1
$ repo sync
[ 编译Android ]
接下来开始编译:
$ make -j`grep '^processor' /proc/cpuinfo | wc -l`
上面的命令中,-j参数告诉make启动多个并行任务进行编译,在支持多核的CPU上能加快编译速度。如果你知道你CPU是几核的,可以直接把这部分替换成-j2(双核)。
我在编译的过程中遇到下面的错误:
************************************************************
You are attempting to build on a 32-bit system.
Only 64-bit build environments are supported beyond froyo/2.2.
************************************************************
这是因为在Makefile中检测了CPU的字长。我直接把build/core/main.mk中下面的话注释掉:
#ifneq (64,$(findstring 64,$(build_arch)))
#$(warning ************************************************************)
#$(warning You are attempting to build on a 32-bit system.)
#$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
#$(warning ************************************************************)
#$(error stop)
#endif
接下来又遇到下面的错误:
Docs droiddoc: out/target/common/docs/api-stubs
Could not load ‘clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/api-stubs-timestamp] Error 45
make: *** Waiting for unfinished jobs….
Could not load ‘clearsilver-jni’
java.library.path = out/host/linux-x86/lib
make: *** [out/target/common/docs/doc-comment-check-timestamp] Error 45
这是由于clearsilver在编译时如果检测到使用Java JDK 6,就使用64位编译。要避开此错误,需要修改下面四个文件:
* external/clearsilver/cgi/Android.mk
* external/clearsilver/java-jni/Android.mk
* external/clearsilver/util/Android.mk
* external/clearsilver/cs/Android.mk
把这四个Makefile中的下列语句注掉即可:
# This forces a 64-bit build for Java6
# Comment by Easwy
# LOCAL_CFLAGS += -m64
# LOCAL_LDFLAGS += -m64
然后在external/clearsilver目录中执行一下make clean,然后回到项目根目录,继续make即可。
当编译完成时,生成的image文件放在out/target/product/generic目录中。
常见问题:
1:issue "You are attempting to build on a 32-bit system"
How to fix:
$ vim build/core/main.mk
change
ifneq (64,$(findstring 64,$(build_arch)))
to
ifneq (i686,$(findstring i686,$(build_arch)))
$(warning ************************************************************)
$(warning You are attempting to build on a 32-bit system.)
$(warning Only 64-bit build environments are supported beyond froyo/2.2.)
$(warning ************************************************************)
$(error stop)
endif
external/clearsilver/cgi/Android.mk,
external/clearsilver/java-jni/Android.mk,
external/clearsilver/util/Android.mk,
external/clearsilver/cs/Android.mk
change
LOCAL_CFLAGS += -m64
LOCAL_LDFLAGS += -m64
to
LOCAL_CFLAGS += -m32
LOCAL_LDFLAGS += -m32
2:issue "host C: libclearsilver-jni <= external/clearsilver/java-jni/j_neo_util.c
In file included from /usr/include/features.h:378,
from /usr/include/string.h:26,
from external/clearsilver/java-jni/j_neo_util.c:1:
/usr/include/gnu/stubs.h:9:27: error: gnu/stubs-64.h: 没有那个文件或目录
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libclearsilver- jni_intermediates/j_neo_util.o]错误"
How to fix:
sudo apt-get install lib64z1-dev libc6-dev-amd64 g++-multilib lib64stdc++6
3:issue:
host SharedLib: libneo_util (out/host/linux-x86/obj/lib/libneo_util.so)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.a when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.so when searching for -lstdc++
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.3.4/libstdc++.a when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libneo_util.so] Error 1
How to fix:
4
frameworks/base/core/java/android/app/ListActivity.java:319: inconvertible types
found : android.widget.AdapterView<capture of ?>
required: android.widget.ListView
onListItemClick((ListView)parent, v, position, id);
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
How to fix:
其实JDK的版本低了,用了 1.5.0_06的版本,用1.6就可以了
发表评论
-
Android Activity的四种LaunchMode!!!
2012-04-10 16:27 595本文转自: http://marshal.easymorse. ... -
Android 模拟器接受UDP/TCP数据报
2012-02-06 10:08 2619今天在使用模拟器调试 ... -
Android模拟器中创建和使用SDCard
2012-01-30 15:33 1018... -
Android DDD 调试
2012-01-18 14:49 1510Google为Android应用开发提供了eclipse加插件 ... -
Android源码:如何单独编译OpenCores
2012-01-17 17:38 1205一:编译步骤: 1. cd <opencore存放路径 ... -
Android 进程通信
2012-01-17 17:34 611http://developer.android.com/gu ... -
值得记下的手机博客
2012-01-17 14:40 673http://blog.csdn.net/cuijpus -
Android NDK Log
2012-01-13 16:17 1495Android NDK 打印log ... -
玩转Android Provider
2012-01-13 16:02 836参考:http://blog.csdn.net/yan8024 ... -
自定义Adnroid SDK
2012-01-13 14:14 830修改了Android的源码后, make PRODUCT-sd ... -
Android 源码修改
2012-01-13 14:10 1337(1) 支持mmm,mm等命令: 在source的根目录下执行 ... -
Android 源码目录结构说明
2012-01-11 10:06 602转自http://www.5adev.com/a/androi ...
相关推荐
Learn how to build an interactive source code analytics system using Roslyn and JavaScript. This concise 150 page book will help you create and use practical code analysis tools utilizing the new ...
Learn how to build an interactive source code analytics system using Roslyn and JavaScript. This concise 150 page book will help you create and use practical code analysis tools utilizing the new ...
Android Programming Tutorials gives you hands-on instruction in how to build sophisticated Android applications, using many of the technologies outlined in CommonsWare’s other Android books....
including Git and Gradle: this book covers how Android Studio works seamlessly with Git, for source control, and Gradle, a build and test tool. In addition, this book demonstrates how to develop/...
Decompiling Android looks at the the reason why Android apps can be decompiled to recover their source code, what it means to Android developers and how you can protect your code from prying eyes....
then Clean and Build the hold project to regenerate the library Then just add library module as a dependency to your existing project. How to Use it It is dead simple, you can see magic in the ...
Learn Spring Boot and how to build Java-based enterprise, web, and microservice applications with it. In this book, you'll see how to work with relational and NoSQL databases, build your first ...
With actionable real-world source, Advanced Android 4 Games shows you how to build more sophisticated and addictive Android games, harnessing the power of these recent advancements. * Coverage of ...
Understand how to build an Android mobile app from source Set up a development or debuggi ng environment for mobile apps Integrate with the Nexus dependency management and application release tool ...
For Complete Beginners to Android!... With all project source code included with the book, and support forums right on our site, it’s simply the best way to start your Android development career.
The Way to Go,: A Thorough Introduction to the Go Programming Language 英文书籍,已Cross the wall,从Google获得书中源代码,分享一下。喜欢请购买正版。 目录如下: Contents Preface......................
Features four complete projects developers can build using various sensors and indicators/actuators, including source code Gives Android developers the tools to create powerful, sophisticated projects...
Intro This is the source code for bVNC, aRDP, aSPICE and ...Building from scratch (I-b) is known to build with Android NDK r14b. Please note that while for now there is a reference to eclipse_project
Gain examples of all three tools in real development situations Learn how to build clean, manageable code Use a complete application toolkit from start to finish, server to client Understand the ...
Gain examples of all three tools in real development situations Learn how to build clean, manageable code Use a complete application toolkit from start to finish, server to client Understand the ...
I wanted to build a proof of concept prototype version of Flappy Bird using Delphi XE5 Firemonkey and this is what I came up with. The game is called Flappy Firemonkey and I built it in a few hours. ...
In this indispensable book, Diomidis Spinellis uses more than 600 real-world examples to show you how to identify good (and bad) code: how to read it, what to look for, and how to use this knowledge ...
Paperback: 214 pages ...Learn how to keep pace with and navigate the details of fast moving open source projects Overcome obstacles in policy development through directed experimentation
Run ./gradlew addSources to generate source code for all subprojects. To build all apps with gradle: ./buildWithGradle To build all apps with buck Setup Mac OS X brew update brew install ant watchman ...
Finally, he walks you through using filesystem images to boot Android and learning to build customized ROMs to support any new Android device. Throughout, Ye provides extensive downloadable code you ...