如何设定android开发环境

 
这里来介绍一下如何设定android的开发环境。
我们分为几个阶段:
1. linux基本环境设定
2. android apk 开发环境设定
3. android os 开发环境设定

首先,linux环境设定:

1. 安装 ubuntu version 10.04 LTS 64bit (以下是以ubuntu来举例说明)
1.1. 设定 eth0.
1.2. 设定 samba service. (这个是为了方便与windows共享档案用)
参考资料: http://ithelp.ithome.com.tw/question/10027945
1.3. 最好执行 system / administration / update manager 将系统更新到最新.
2. 安装浏览器 google chrome. (也可以用内建的firefox)
下载位置: https://www.google.com/chrome?hl=zh-TW
3. 安装 ssh (方便用其他电脑连线进去作业)
参考资料: http://twntwn.info/blog/ajer001/archives/2822
安装指令: sudo apt-get install ssh
4. 安装中文输入法 gcin.
参考资料: http://cle.linux.org.tw/trac/wiki/GcinInstallUbuntu


接下来,安装 android apk 开发环境:

参考资料: http://developer.android.com/sdk/requirements.html

1. 安装 jdk 6 (non-rpm version for ubuntu)
参考资料: http://source.android.com/source/initializing.html
安装指令: sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
安装指令: sudo apt-get update
安装指令: sudo apt-get install sun-java6-jdk
2. 安装 eclipse
下载位置: http://www.eclipse.org/downloads/
3. 安装 android sdk
参考资料: http://developer.android.com/sdk/installing.html
4. 安装 android adt from eclipse.
参考资料: http://developer.android.com/sdk/eclipse-adt.html
5. 安装相关 android sdk 元件.
5.1. 设定 android sdk folder for eclipse.
5.2. 启动 android sdk manager and download necessary components.
6. 安装 android ndk (非必要步骤)
参考资料: http://developer.android.com/sdk/ndk/index.html


最后,安装 android os 开发环境

1. 安装必要元件.
参考资料: http://source.android.com/source/initializing.html    (key word: "Installing required packages")
安装指令: sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc
安装指令: sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
安装指令: sudo apt-get install sharutils    //for uudecode

2. 设定 USB Access 权限
参考资料: http://source.android.com/source/initializing.html (key word: "Configuring USB Access")
安装指令: sudo vim /etc/udev/rules.d/51-android.rules
add following lines:
----------------------------------------------------------
SUBSYSTEM=="usb", SYSFS{idVendor}=="vendor id here", MODE="0666"
SUBSYSTEM=="usb", SYSFS{idVendor}=="vendor id here", OWNER="user name here" GROUP="group name here"
----------------------------------------------------------
!!NOTE: This is known to work on both Ubuntu Hardy Heron (8.04.x LTS) and Lucid Lynx (10.04.x LTS).

3. 设定 ccache (加快 build image 速度)
参考资料: http://source.android.com/source/initializing.html (key word: "Setting up ccache")
安装指令: mkdir ~/data/ccache
安装指令: vim ~/.bashrc
add following lines at end of file:
----------------------------------------------------------
export USE_CCACHE=1
export CCACHE_DIR=~/data/ccache
----------------------------------------------------------

4. 设定开启档案最大值
安装指令: sudo vim /etc/security/limits.conf
add following lines at end of file:
----------------------------------------------------------
user_name_here      -       nofile          4096
root             -       nofile          4096
----------------------------------------------------------




其他实用的设定
1. format history command:
安装指令: vim ~/.bashrc
add following line at end of file:
----------------------------------------------------------
export HISTTIMEFORMAT="%F %T "
----------------------------------------------------------

2. format vim editor
安装指令: vim ~/.vimrc
add following lines
----------------------------------------------------------
set hlsearch            "高亮度反白
set backspace=2         "可随时用倒退键删除
set autoindent          "自动缩排
set ruler               "可显示最后一行的状态
set showmode            "左下角那一行的状态
set nu                  "可以在每一行的最前面显示行号啦!
set bg=dark             "显示不同的底色色调
syntax on               "进行语法检验,颜色显示。
----------------------------------------------------------
REF://http://astone-working.blogspot.tw/2011/12/android.html
相关文章