這裡來介紹一下如何設定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 "進行語法檢驗,顏色顯示。
----------------------------------------------------------
2011年12月29日 星期四
2011年11月18日 星期五
android CTS 介紹---cts plan 包含哪些東西
1. CTS從大到小包含了
Plan > package > suite > case > method
Plan:
User can create plan in cts shell. Plan should include packages, suites, cases or methods. Picture below shows the “add plan” command.

Case:
Method:
Plan > package > suite > case > method
Plan:
User can create plan in cts shell. Plan should include packages, suites, cases or methods. Picture below shows the “add plan” command.
- Cts test plan comes from [android source tree]/out/host/linux-x86/repository/plans/[xml file]
;
- User can also create cts plan by adding xml file manually, without cts shell. This means when user types command “ls --plan”, cts shell search xml immediately.
- Cts shell will check contents in plan when processing user command, following picture shows the error message for the item.
Package comes from [ android source tree]/out/host/linux-x86/repository/plans/*.xml- Each package should responds to one xml and one apk file in
[ android source tree]/out/host/linux-x86/repository/testcase/. (but some package don’t.)
- Following picture shows the xml structure. It show the relationship between suite, TestCase(Case) and Test(Method).
- And picture below shows the source code for corresponded class method.
- We can find Suite in each xml file in
[ android source tree]/out/host/linux-x86/repository/testcase/*.xml.
Case:
- It corresponds to class name in java file.
- Test case is recorded in xml as suite child node. We can find them in source code as a class name.
Method:
- Method is recorded in xml as TestCase child node. We can find them in source code as a class method.
android CTS 介紹---運作方式
需要設備.
運作流程.
- Host side: PC with linux OS or windows OS.
- Client side: tablet.
運作流程.
- When cts start on host pc. Host pc will install test apk to tablet via adb.
- After installing, tablet will start apk to test. And send result to host pc.
- Host pc send adb command to remove apk on tablet.
- Host pc gathers result information and generates xml report.
2011年10月31日 星期一
今早看到一則新聞:
懂得閃避的文字 -- 用 Kinect 便能解決 Keynote 之「遮蔽問題」
大意是說,日本明治大學利用 Kinect 來解決投影片會投到人身上的問題。其動機是非常好的,不過,就現實生活來講,演講者可以粗略地分成兩種:第一種是只站在演講桌後方,動也不動,這樣的人應該用不到這套技術。第二種人可能像Jobs Steve一樣在投影機前面亂亂跑,這樣的人可能需要這樣的技術。
所以我們就第二種人來討論,當演講者在投影機前面亂亂跑的時候,投影片上的文字圖案應該也會亂亂跑,我想如果我是聽演講的人,應該很不舒服吧。而且可能會模糊焦點。
如果,就這樣的狀況來探討的話,是否可以對這樣的技術再做一些加強,比如說:
1. 投影片上的文字、圖案都不需要自動調整,只要不打光在演講者身上就可以了。
2. 前面的作法是不打光在演講者身上,這樣的效果很容易造成演講者光線偏暗。或許我們可以利用Kinect捕捉人影的技術,動態在演講者身上投射微光。讓整場演講的效果更專注在演講者身上。
也許這樣的投影機會更受消費者歡迎。這樣的技術不難,也許再過一陣子就會有廠商開發出來了喔!
懂得閃避的文字 -- 用 Kinect 便能解決 Keynote 之「遮蔽問題」
大意是說,日本明治大學利用 Kinect 來解決投影片會投到人身上的問題。其動機是非常好的,不過,就現實生活來講,演講者可以粗略地分成兩種:第一種是只站在演講桌後方,動也不動,這樣的人應該用不到這套技術。第二種人可能像Jobs Steve一樣在投影機前面亂亂跑,這樣的人可能需要這樣的技術。
所以我們就第二種人來討論,當演講者在投影機前面亂亂跑的時候,投影片上的文字圖案應該也會亂亂跑,我想如果我是聽演講的人,應該很不舒服吧。而且可能會模糊焦點。
如果,就這樣的狀況來探討的話,是否可以對這樣的技術再做一些加強,比如說:
1. 投影片上的文字、圖案都不需要自動調整,只要不打光在演講者身上就可以了。
2. 前面的作法是不打光在演講者身上,這樣的效果很容易造成演講者光線偏暗。或許我們可以利用Kinect捕捉人影的技術,動態在演講者身上投射微光。讓整場演講的效果更專注在演講者身上。
也許這樣的投影機會更受消費者歡迎。這樣的技術不難,也許再過一陣子就會有廠商開發出來了喔!
2011年10月3日 星期一
如何建立android unit test專案
前置作業:
1. 先建立要被測試的專案,假設要被測試的專案是com.myCompany.myHello.要被測試的class是MyHelloActivity.

2. 開始建立unit test project
步驟:
1. 在Eclipse 裡開新專案, new > project > Android > Android test Project.

2. 設定值如下說明
2.1. 假設test專案名稱為myTestProject.
2.2. 被測試專案為myHello.

3. 完成之後,會在eclipse的package explorer出現一個test專案,如下:

4. 接著新增加一個test case class,如下圖。
為什麼要用ActivityInstrumentationTestCase2,原文解釋:Android offers several, but the one that tests in the most realistic environment is ActivityInstrumentationTestCase2, so you will use it as the base class. Like all activity test case classes, ActivityInstrumentationTestCase2 offers convenience methods for interacting directly with the UI of the application under test.

5. 完成之後eclipse自動generate出一個myTestClass.java檔,請加入
import com.myCompany.MyHelloActivity;
並MyTestClass的建構子,如下:
這裡的”com.myCompany”指的是package name.,也就是告訴super class說,我要使用com.myCompany的MyHelloActivity的class.
6. 加入setUp() function,這個function是整個test project在開始test 程序之前會先被呼叫的,在這裡需要先確保需要使用到的變數都先被初始化。
在setUp()裡,也許你需要加上
setActivityInitialTouchMode(false);
如果在你的test procedure裡有送出一些key events,一定要將touch mode設定成off。如果沒有用到key events,可以不管這一行。
7. 加入preconditions() function,這個function是用來做前置測試用,先確保等一下要被呼叫的test functions裡面用到的變數,物件都是有用的資訊。跟setUp()作用很相似,Android development help裡面提到,preconditions只會被呼叫一次,但是setUp是每一個test function被呼叫之前都會先被執行一次。
8. 原文補充:The purpose of testing initial conditions is not the same as using setUp(). The JUnit setUp() runs once before each test method, and its purpose is to create a clean test environment. The initial conditions test runs once, and its purpose is to verify that the application under test is ready to be tested.
10. 最後加入要測試的functions,根據測試結果只要是test開頭的function都會被執行。
11. 執行unit test

12. 範例原始碼
13. 執行結果,如下圖。
根據這樣的資訊,我們可以知道在每個test procedure被執行之前,都會先呼叫setUp(),所以我們應該將變數的初始化放在這個地方。Android development裡面提到testPreconditions只會被執行一次,但是系統執行test開頭的的順序似乎是以function name的ascii順序來執行的。

14. 參考來源:
Android develop: http://developer.android.com/resources/tutorials/testing/helloandroid_test.html
1. 先建立要被測試的專案,假設要被測試的專案是com.myCompany.myHello.要被測試的class是MyHelloActivity.

2. 開始建立unit test project
步驟:
1. 在Eclipse 裡開新專案, new > project > Android > Android test Project.
2. 設定值如下說明
2.1. 假設test專案名稱為myTestProject.
2.2. 被測試專案為myHello.
3. 完成之後,會在eclipse的package explorer出現一個test專案,如下:

4. 接著新增加一個test case class,如下圖。
為什麼要用ActivityInstrumentationTestCase2,原文解釋:Android offers several, but the one that tests in the most realistic environment is ActivityInstrumentationTestCase2, so you will use it as the base class. Like all activity test case classes, ActivityInstrumentationTestCase2 offers convenience methods for interacting directly with the UI of the application under test.
5. 完成之後eclipse自動generate出一個myTestClass.java檔,請加入
import com.myCompany.MyHelloActivity;
並MyTestClass的建構子,如下:
這裡的”com.myCompany”指的是package name.,也就是告訴super class說,我要使用com.myCompany的MyHelloActivity的class.
6. 加入setUp() function,這個function是整個test project在開始test 程序之前會先被呼叫的,在這裡需要先確保需要使用到的變數都先被初始化。
在setUp()裡,也許你需要加上
setActivityInitialTouchMode(false);
如果在你的test procedure裡有送出一些key events,一定要將touch mode設定成off。如果沒有用到key events,可以不管這一行。
7. 加入preconditions() function,這個function是用來做前置測試用,先確保等一下要被呼叫的test functions裡面用到的變數,物件都是有用的資訊。跟setUp()作用很相似,Android development help裡面提到,preconditions只會被呼叫一次,但是setUp是每一個test function被呼叫之前都會先被執行一次。
8. 原文補充:The purpose of testing initial conditions is not the same as using setUp(). The JUnit setUp() runs once before each test method, and its purpose is to create a clean test environment. The initial conditions test runs once, and its purpose is to verify that the application under test is ready to be tested.
10. 最後加入要測試的functions,根據測試結果只要是test開頭的function都會被執行。
11. 執行unit test
12. 範例原始碼
13. 執行結果,如下圖。
根據這樣的資訊,我們可以知道在每個test procedure被執行之前,都會先呼叫setUp(),所以我們應該將變數的初始化放在這個地方。Android development裡面提到testPreconditions只會被執行一次,但是系統執行test開頭的的順序似乎是以function name的ascii順序來執行的。

14. 參考來源:
Android develop: http://developer.android.com/resources/tutorials/testing/helloandroid_test.html
2011年9月29日 星期四
[Android App] 緊急電話簿 v1.5
終於改版了,這次也算是大翻修,增加了交通運輸的服務電話,在經過一些思考之後,交通服務電話應該是比較會被大家用到的,也希望大家在緊急的時候都能得到協助。
趕緊來介紹一下新版本功能吧!
緊急電話簿更新 v1.5 版本了。
新的版本修改部分如下:
[修改部分]:
1. 修正永豐銀行、新光銀行服務電話。
2. 加大字體大小。
3. 自動辨識螢幕大小適時旋轉,提供更方便的操作介面。
[新增部分]:
增加交通運輸公司服務電話,有:
鐵路部分:高鐵、台鐵、台北捷運、高雄捷運。
航空部分:桃園機場、松山機場、高雄小港機場、中華航空、立榮航空、長榮航空、華信航空、復興航空、遠東航空、德安航空。
國道客運部分:三重客運、國光客運、日統客運、台中客運、和欣客運、統聯客運、阿羅哈客運、新竹客運。
相關連結
趕緊來介紹一下新版本功能吧!
緊急電話簿更新 v1.5 版本了。
新的版本修改部分如下:
[修改部分]:
1. 修正永豐銀行、新光銀行服務電話。
2. 加大字體大小。
3. 自動辨識螢幕大小適時旋轉,提供更方便的操作介面。
[新增部分]:
增加交通運輸公司服務電話,有:
鐵路部分:高鐵、台鐵、台北捷運、高雄捷運。
航空部分:桃園機場、松山機場、高雄小港機場、中華航空、立榮航空、長榮航空、華信航空、復興航空、遠東航空、德安航空。
國道客運部分:三重客運、國光客運、日統客運、台中客運、和欣客運、統聯客運、阿羅哈客運、新竹客運。
相關連結
| 程式下載:Android Market 連結 |
| [Android App] 緊急電話簿 v1.2 |
| [Android App] 緊急電話簿 |
希望,這份資料可以提供給大家必要時的幫助。
2011年9月27日 星期二
UML筆記---簡介
什麼是UML?
字面翻譯:統一塑模語言(Unified Modeling Language)
為了讓所有設計、撰寫軟體的相關人員有共通的語言,達到軟體開發的目標。根據wiki說明,目前UML並非工業標準,但是正在逐漸變成工業標準。UML裡定義了很多圖表讓設計人員,開發人員可以明白系統功能。
常見的圖表可以分成三大類:
結構性圖形(Structure diagrams)強調的是系統式的塑模:
類別圖(Class Diagram)
元件圖(Component diagram)
複合結構圖(Composite structure diagram)
部署圖(Deployment diagram)
物件圖(Object diagram)
套件圖(Package diagram)
剖面圖(Profile diagram)
行為式圖形(Behavior diagrams)強調系統模型中觸發的事件:
活動圖(Activity diagram)
狀態機圖(State Machine diagram)
使用個案圖 (Use Case Diagram)
溝通性圖形(Interaction diagrams)屬於行為圖形的子集合,強調系統模型中的資料流程:
通信圖(Communication diagram)
交互概述圖(Interaction overview diagram) (UML 2.0)
時序圖(Sequence diagram)
時間圖(UML Timing Diagram) (UML 2.0)
參考資料:統一塑模語言 on wiki
訂閱:
文章 (Atom)