This is featured post 1 title
Replace these every slider sentences with your featured post descriptions.Go to Blogger edit html and find these sentences.Now replace these with your own descriptions.
This is featured post 2 title
Replace these every slider sentences with your featured post descriptions.Go to Blogger edit html and find these sentences.Now replace these with your own descriptions.
This is featured post 3 title
Replace these every slider sentences with your featured post descriptions.Go to Blogger edit html and find these sentences.Now replace these with your own descriptions.
MonkeyRunner 紀錄
紀錄:
首先MonkeyRunner主要是調用
/android-sdk-linux/tools/monkeyrunner
來自動化執行腳本
步驟1
在/android-sdk-linux/tools/中建立專屬的測試腳本資料夾,其中放入測試用腳本,
假設專案名稱為Project1,建立/android-sdk-linux/tools/Project1_script
步驟2
把專案apk(Project1.apk)放入步驟1建立的資料夾中並建立測試腳本(Project1_script.py),
測試腳本內容可參考以下範例,必須修改
device.installPackage('../Project1_script/Project1.apk')
->路徑必須對應apk位置
package
= 'abc.efg.hij' -> package name
activity
= 'abc.efg.hij.xxxActivity' -> activity name
範例如下
Project1_script.py
#
Imports the monkeyrunner modules used by this program
from
com.android.monkeyrunner import MonkeyRunner, MonkeyDevice,
MonkeyImage
#
Connects to the current device, returning a MonkeyDevice object
device
= MonkeyRunner.waitForConnection()
#
Installs the Android package. Notice that this method returns a
boolean, so you can test
#
to see if the installation worked.
device.installPackage('../Project1_script/Project1.apk')
#
sets a variable with the package's internal name
package
= 'abc.efg.hij'
#
sets a variable with the name of an Activity in the package
activity
= 'abc.efg.hij.xxxActivity'
#
sets the name of the component to start組合(package和activity)
runComponent
= package + '/' + activity
#
Runs the component
device.startActivity(component=runComponent)
#
Do something u want to do....
2.如何執行測試腳本:
使用Terminal移動到/android
sdk/tools/Project1_script資料夾,再輸入
../monkeyrunner
Project1_script.py
3.相關的內容在android
api 中都有使用說明
4.常用方法紀錄
MonkeyRunner.sleep(n)
->等待n秒
device
= MonkeyRunner.waitForConnection()
device.press('KEYCODE_NUMPAD_1','DOWN_AND_UP')
-> 模擬虛擬鍵盤輸入1
device.press('KEYCODE_NUMPAD_7','DOWN_AND_UP')
-> 模擬虛擬鍵盤輸入7
device.press('KEYCODE_NUMPAD_2','DOWN_AND_UP')
-> 模擬虛擬鍵盤輸入2
device.press('KEYCODE_NUMPAD_DOT','DOWN_AND_UP')
-> 模擬虛擬鍵盤輸入 .
以上指令可用
device.type('172.')
取代
device.touch(384,199,'DOWN_AND_UP')
-> 點擊螢幕x:384
y:199座標
start
= (100,100) -> 拖曳起點
end
= (100,120) -> 拖曳終點
device.drag(start,end,1,10)
-> 開始拖曳
device.getProperty()
-> 可獲得系統資訊,
參考http://developer.android.com/tools/help/MonkeyDevice.html#table1
如
width
= int(device,getProperty('display.width') -> 螢幕寬度
height
= int(device.getProperty('display.height') -> 螢幕高度
#註解
print
'顯示訊息'
Git error: 解決在Gerrit網頁上submit patch set 出現衝突的情況
Cause:
在Gerrit等待code review通過期間,若有協同開發者先merge commit,且該commit和自己的commit
發生衝突的情況
Solution:
1.
在發生conflict
的 branch上
執行
git pull --rebase origin master
此指令說明如下
This
command will fetch new commits from the remote and then rebase your
local commits on top of them. It will temporarily set aside the
changes you've made in your branch, apply all of the changes that
have happend in master to your working branch, then merge (recommit)
all of the changes you've made back into the branch. Doing this will
help avoid future merge conflicts. Plus, it gives you an opportunity
to test your changes against the latest code in master.
Once
you are satisfied with your change set and you've rebased against
master, you are ready to push your code to Gerrit for review.
簡單的說:把master上已合併的commit(但在目前branch不存在),接到目前的branch上,再把
目前branch的commit接到最後面(最新)
當然在Gerrit網頁上合併會發生衝突,所以執行這個指令之後在本地端也會發生衝突,把執行後的提示紀錄下來如下
When
you have resolved this problem run "git rebase --continue".
If
you would prefer to skip this patch, instead run "git rebase
--skip".
To
check out the original branch and stop rebasing run "git rebase
–abort".
第一行為當修改衝突後,要執行的指令
2.修改發生衝突的地方,使用vim修改
3.把修改後的檔案全部
git
add
4.git
add 所有的檔案之後執行 git
rebase --continue
5.最後
git
push origin HEAD:refs/for/master
6.必須重新等待code
review
Eclipse Error: Indexer runs out of memory
Cause:
編譯jni會產生大量的檔案,特別是 C/C++ indexer 會建立索引 若eclipse初始記憶體太小會導致
out of memory 的錯誤
Solution:
在 eclipse.ini檔案中可設定記憶體限制,主要調整以下幾個數值
初始設定
--launcher.XXMaxPermSize
256m
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m
調整後
--launcher.XXMaxPermSize
512m
-XX:MaxPermSize=512m
-Xms80m
-Xmx1000m
細節參考
http://wiki.eclipse.org/Eclipse.ini
編譯jni會產生大量的檔案,特別是 C/C++ indexer 會建立索引 若eclipse初始記憶體太小會導致
out of memory 的錯誤
Solution:
在 eclipse.ini檔案中可設定記憶體限制,主要調整以下幾個數值
初始設定
--launcher.XXMaxPermSize
256m
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m
調整後
--launcher.XXMaxPermSize
512m
-XX:MaxPermSize=512m
-Xms80m
-Xmx1000m
細節參考
http://wiki.eclipse.org/Eclipse.ini
更新 Git 版本
主要原因是建置 Android Build 環境時, repo 的初始化需要 git 1.7.2以上的版本,必須升級 git
方法:
終端機輸入
1. sudo apt-add-repository ppa:git-core/ppa
2. sudo apt-get update
3. sudo apt-get install git-core
即可更新 git 版本
方法:
終端機輸入
1. sudo apt-add-repository ppa:git-core/ppa
2. sudo apt-get update
3. sudo apt-get install git-core
即可更新 git 版本
ubuntu 安裝 sun-java-6 及切換使用的jdk
A.建議先安裝open-jdk
直接輸入 sudo apt-get install default-jdk
B.再安裝sun-java-6-jdk
照著AOSP 官網的教學操作
1. sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
2. sudo apt-get update
3. sudo apt-get install sun-java6-jdk
第3步驟會出現錯誤 "找不到套件之類的...."
修正方式:
1. sudo add-apt-repository ppa:ferramroberto/java
or sudo add-apt-repository ppa:flexiondotorg/java
2. sudo apt-get update
3. sudo apt-get install sun-java6-jdk
即可成功安裝,過程中會要求設定 DLJ ,按確定即可
完成後使用以下指令切換 java 版本
終端機輸入
update-alternatives --config java
出現
Selection Path 優先級 Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
直接輸入 sudo apt-get install default-jdk
B.再安裝sun-java-6-jdk
照著AOSP 官網的教學操作
1. sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
2. sudo apt-get update
3. sudo apt-get install sun-java6-jdk
第3步驟會出現錯誤 "找不到套件之類的...."
修正方式:
1. sudo add-apt-repository ppa:ferramroberto/java
or sudo add-apt-repository ppa:flexiondotorg/java
2. sudo apt-get update
3. sudo apt-get install sun-java6-jdk
即可成功安裝,過程中會要求設定 DLJ ,按確定即可
完成後使用以下指令切換 java 版本
終端機輸入
update-alternatives --config java
出現
Selection Path 優先級 Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
0為預設的選項(openjdk),2為剛剛安裝的sunjdk,輸入數字切換
jenkins_備份及還原完整系統
只需要將 JENKINS_HOME 所指的目錄內所有資料複製起來即可完成備份,
如JENKINS_HOME=/home/jenkins ,就把/home/jenkins所有資料複製起來
,備份和還原時儘量先停止jenkins (/etc/init.d/jenkins stop)
備份:
1.先登入 root 權限
2.建立並移動到rcserver使用者的資料夾內
mkdir jenkins_backup
cd jenkins_backup
3.複製所有JENKINS_HOME 所有資料夾
cp -adr /home/jenkins/* ./ (為jenkins_backup)
還原:
1.先登入 root 權限
2.移動到放置所有備份資料的資料夾中
cd jenkins_backup
2.複製備份檔到 JENKINS_HOME 所指資料夾
cp -adr ./* /home/jenkins/
jenkins_備份及還原專案
說明:
jenkins的專案全部都放在 jobs 資料夾下,只要複製專案資料夾,就能進行備份還原動作
本地和遠端動作類似,差別在於遠端需要ssh和sftp
要注意複製專案時是否有將專案內全部資料都複製齊全
本地備份
1. 開啟終端機,取得root權限
sudo -s
2.複製想備份的專案
cp -adr /home/jenkins/jobs/專案名 目的路徑
本地還原
1.還原專案
cp -adr 來源路徑 /home/jekins/jobs
備份及還原儘量在 jenkins 停止的狀態下進行,經測試備份及還原的進行可以不必停止jenkins
不過還原後必須重啟jenkins,備份的專案才會顯示
遠端備份
1.使用ssh指令遠端登入server
2.移動到/home/jenkins/jobs目錄中
3.針對要備份的專案進行壓縮
壓縮:
tar zcvf 壓縮檔名.tar.gz 來源檔(專案名)
4.離開ssh
5.使用sftp將剛剛製作的壓縮檔get到本地端
(要注意本地端放置備份壓縮檔的目錄權限,如果目錄是需要root,則使用sftp指令前必須先切換到root權限再使用sftp)
遠端還原
1.先使用sftp將備份壓縮檔put到遠端
(由於sftp無法切換到root權限,所以無法直接把壓縮檔put到/home/jenkins/jobs中,先put到可以put的目錄)
2.離開sftp,使用ssh登入遠端,切換到root權限並將備份壓縮檔解壓縮到/home/jenkins/jobs中
3.重啟jenkins

