Chinaunix首页 | 论坛 | 博客
  • 博客访问: 220151
  • 博文数量: 37
  • 博客积分: 1627
  • 博客等级: 上尉
  • 技术积分: 396
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-06 12:08
文章分类

全部博文(37)

文章存档

2018年(1)

2016年(2)

2015年(2)

2014年(1)

2012年(8)

2011年(9)

2010年(14)

我的朋友

分类: LINUX

2011-04-06 15:36:09

1. 安装编译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
 
$ sudo apt-get install lib64z1-dev libc6-dev-amd64 g++-multilib lib64stdc++6
 
$ sudo aptitude install sun-java6-jdk

2. 使用repo工具下载android源码
$ cd ~$ mkdir bin$ curl >~/bin/repo$ chmod a x ~/bin/repo
PATH=$PATH:~/binexport PATH $ mkdir mydroid$ cd mydroid$ repo init -u git://android.git.kernel.org/platform/manifest.git$ repo sync (这个时候会等很久,要有耐心,我可是直接下了一个晚上!)
3. 源码下载完后,不要更改几个文件:

  3.1 修改下面四个文件:

·         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 

  
 3.2 在打上个patch :
--- ./build/core/main.mk.org    2011-04-02 22:24:20.724845811 0800
./build/core/main.mk        2011-04-02 22:24:56.317325224 0800
@@ -72,7 72,7 @@
 
 ifeq ($(BUILD_OS),linux)
 build_arch := $(shell uname -m)
-ifneq (64,$(findstring 64,$(build_arch)))
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.)
4. 开始编译
  make 
(这里也会要很久,慢慢等吧。)
5.  编译成功后,可以运行模拟器看看效果。
  $declare -x ANDROID_PRODUCT_OUT="./out/target/product/generic"
  $./out/host/linux-x86/bin/emulator -shell
或者:
执行gedit ~/.bashrc
export ANDROID_PRODUCT_OUT=~/Android/source/out/target/product/generic
ANDROID_PRODUCT_OUT_BIN=~/Android/source/out/host/linux-x86/bin
export PATH=${PATH}:${ANDROID_PRODUCT_OUT_BIN}:${ANDROID_PRODUCT_OUT};

最后,同步这些变化并启动模拟器:

$ source ~/.bashrc
$ cd ~/Android/source/out/target/product/generic
$ emulator -system system.img -data userdata.img -ramdisk ramdisk.img

6.效果图如下:
     (没办法,不知道怎么显示图片在博客里)


编译出错处理:(ubuntu11.10 + android 2.3
错误2:
host C++: libutils <= frameworks/base/libs/utils/RefBase.cpp
frameworks/base/libs/utils/RefBase.cpp: In member function ‘void android::RefBase::weakref_type::trackMe(bool, bool)’:
frameworks/base/libs/utils/RefBase.cpp:483:67: error: passing ‘const android::RefBase::weakref_impl’ as ‘this’ argument of ‘void android::RefBase::weakref_impl::trackMe(bool, bool)’ discards qualifiers [-fpermissive]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1
解决:
gedit frameworks/base/libs/utils/Android.mk
Change the line:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)
To:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive



错误3:
In file included from external/yaffs2/yaffs2/yaffs_tagsvalidity.c:17:0:
external/yaffs2/yaffs2/yaffs_tagsvalidity.h:23:6: warning: redundant redeclaration of ‘yaffs_InitialiseTags’ [-Wredundant-decls]
external/yaffs2/yaffs2/yaffs_guts.h:888:6: note: previous declaration of ‘yaffs_InitialiseTags’ was here
host Prebuilt: monkeyrunner (out/host/linux-x86/obj/EXECUTABLES/monkeyrunner_intermediates/monkeyrunner)
host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors

解决:
vi external/yaffs2/Android.mk
-- LOCAL_CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
    ++ LOCAL_CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline -Werror

错误4:
Install: out/host/linux-x86/bin/monkeyrunner
host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp
:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
:0:0: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors

解决:
vi ./build/core/combo/HOST_linux-x86.mk
... ...
@@ -58,6 +58,6 @@ HOST_GLOBAL_CFLAGS += \
58 58
   -include $(call select-android-config-h,linux-x86)
59 59
 
60 60
 # Disable new longjmp in glibc 2.11 and later. See bug 2967937.
61
-HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0
  61
+HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
62 62
 
63 63
 HOST_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined




备注:
最近发现 无法连接了,还是用android官方网站的方法吧:

  • Make sure you have a bin/ directory in your home directory, and that it is included in your path:

    $ mkdir ~/bin $ PATH=~/bin:$PATH
  • Download the Repo script and ensure it is executable:

    $ curl > ~/bin/repo $ chmod a x ~/bin/repo
  • Make sure you have a bin/ directory in your home directory, and that it is included in your path:

    $ mkdir ~/bin $ PATH=~/bin:$PATH
  • Download the Repo script and ensure it is executable:

    $ curl > ~/bin/repo $ chmod a x ~/bin/repo
Initializing a Repo client

After installing Repo, set up your client to access the android source repository:

  • Create an empty directory to hold your working files. Give it any name you like:

    $ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY
  • Run repo init to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.

    $ repo init -u

    To check out a branch other than "master", specify it with -b:

    $ repo init -u -b android-2.3.7_r1
Getting the files

To pull down files to your working directory from the repositories as specified in the default manifest, run

$ repo sync
阅读(1564) | 评论(0) | 转发(0) |
0

上一篇:USB API

下一篇:机顶盒里矢量字库的应用

给主人留下些什么吧!~~