用一套方法論去設計許多方法來解決工程上遇到的問題。 即 "一生萬法、萬法圓通"。

Recent in Recipes

3/Food/post-list
顯示具有 Android 標籤的文章。 顯示所有文章
顯示具有 Android 標籤的文章。 顯示所有文章

沒有App Main 的 AndroidTest~ uiauto2

沒有要測試的對象App

完全從首頁Home啟動Test Case



我們關注這三個檔案:

1. 測試程式主檔

2.測試程式屬性檔

3.編譯工具配置檔



Android Studio 專案版本移植 (舊版移植到新版)

 有關Gradle版本的說明可以先參考這裡


從專案目錄夾打看會看到如下架構




再來重點就是修改下面三個檔案 (時否符合最新API的封裝/格式/版號)



舉個例子,用diff 就可以了解其間的差異了
  1. build.gradle

  1. app/build.gradle

  1. gradle-wrapper.property


再來就是透過IDE來移植新版本的套件

  1. migrate to AndroidX



Android App開發 快速入門

Get an activity name of a package and launch it

Older Android

adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

Newer Android Q

adb shell "dumpsys activity activities | grep mResumedActivity"

referring to: https://stackoverflow.com/questions/13193592/adb-android-getting-the-name-of-the-current-activity

Class name

Once the package name has been found (for example com.symbol.wfc.voice), the class name of the main activity has to be determined.

To find all activities published by a package, use the following command & replace com.symbol.wfc.voice by the name of the package to process.
adb shell [enter] dumpsys package | grep -Eo "^[[:space:]]+[0-9a-f]+[[:space:]]+com.symbol.wfc.voice/[^[:space:]]+" | grep -oE "[^[:space:]]+$"

referring to: https://www.zebra.com/us/en/support-downloads/knowledge-articles/evm/Using-ADB-to-Determine-Package-Name-and-Launchable-Activity.html

Package name

To list only 3rd party application
adb shell pm list packages -3

啟動應用程式

格式:am start -n package name / activity name
adb2 shell am start -n com.android.calculator2/com.android.calculator2.Calculator

不管幾層,立馬回到Home畫面

adb2 shell am start -a android.intent.action.MAIN -c android.intent.category.HOME
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] }
Warning: Activity not started, its current task has been brought to the front