Linux, 工作, 生活, 家人

Android, 隨手札記

Andriod 筆記(Run Application, build Image)

最近不小心手滑買了一隻 Android Dev Phone 1 長得和 T-Mobile G1 的外型是一樣的.
雖然還沒有到貨, 但是準備工作要先作好.

== Android Software Development ==

Download SDK
==============

http://code.google.com/intl/zh-TW/android/download_list.html

下載 SDK 之後, 我是解壓在 /home 下

Download Eclipse
==============

安裝之前先移除系統中原有的 Eclipse(?), 直接下載 Eclipse

http://www.eclipse.org/downloads/

我是下載 Eclipse 3.4.1 Classic (151M)

解壓到 /home 下. 目錄在 /home/eclipse

直接到 /home/eclipse 執行 ./eclipse 就可以了 (似乎用 ubuntu 的 openjdk 會比較快)

Download WTP
==============

用 http://code.google.com/intl/zh-TW/android/intro/installing.html#installingplugin 安裝 ADT 的方式, 安裝 WTP.
如果沒有先安裝 WTP, 安裝 ADT 會有問題, ADT 可以用 plugin 下載, 記得選 WTP 3.0.3 就好了, 不用全選.

http://download.eclipse.org/webtools/updates/

Download ADT
==============

http://code.google.com/intl/zh-TW/android/intro/installing.html#installingplugin

Write a sample program
==============

http://code.google.com/intl/zh-TW/android/intro/develop-and-debug.html#developingwitheclipse

我是 New Project 之後, 選 Hello, Activity! 這個 sample code 做為 base.
在 Run 之前, 要先用 create a Launch configuration

順利的話, 就可以叫出 Android Emulator.

== Android Image Development ==

這一段是編 image 的.

Update System Package
==============

http://source.android.com/download

  • 安裝 Git

$ sudo apt-get install git-core gnupg

  • JDK 5.0, update 12 or higher. 個人用了以後, 用 java5 jdk 似乎比較容易成功.

$ sudo apt-get install sun-java5-jdk

  • The following packages: flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev (optional), build-essential, zip, curl.

$ sudo apt-get install flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

  • You might also want Valgrind, a tool that will help you find memory leaks, stack corruption, array bounds overflows, etc.
$ sudo apt-get install valgrind
  • Intrepid (8.10) users may need a newer version of libreadline: (原文有問題, 應該是 libreadline5-dev 才對)

$ sudo apt-get install libreadline5-dev

Get repo tools
==============

* repo is not a new tools. It is just a wrap for git command.

# mkdir ~/bin
# curl http://android.git.kernel.org/repo > ~/bin/repo
# chmod a+x ~/bin/repo
Get Android Source
==================

# cd /home/mydroid
# repo init -u git://android.git.kernel.org/platform/manifest.git

# repo sync

Compile Android Source
==================

# cd /usr/lib/jvm/java-1.5.0-sun
# export JAVA_HOME=`pwd`
# export PATH=$JAVA_HOME/bin:$PATH
# cd /home/mydroid
# make clean
# make

如果中間 compile 有 JVM core dump or compile failed, 記得多試幾次.

(待續)

Ref. Building Android for the Asus Eee PC 701

發佈留言