LoginSignup
84
74

More than 5 years have passed since last update.

adbコマンドを利用したandroid制御まとめ

Last updated at Posted at 2015-03-12

最近非常にadbコマンドを利用するので、覚えておきたいコマンドをメモします。
他の方と重複する内容があるかもしれませんがご容赦ください。

コマンドについては随時追加していく予定です。
私自身既に覚えてしまっているコマンドは記載していませんが、後々整理していきますm(__)m

接続端末を確認

adb devices

端末のバージョン確認

adb shell getprop ro.build.version.release

端末にログイン

adb shell

※ 複数端末と接続していて、端末を指定したログインを行いたい場合、-s オプションを利用します

adb -s <デバイスID> shell

端末ログを確認

adb logcat

端末解像度確認

adb shell wm size

アプリ制御関連

APKインストール

adb install <APKファイル名>

※ APKを更新したい場合、-r オプションを利用する

APKアンインストール

adb uninstall <APKファイル名>

※ chromeを例にしてコマンドを説明すると

アプリ起動

adb shell am start \
          -n com.android.chrome/com.google.android.apps.chrome.Main
ちょっと応用編)

※ URLを指定してchromeを起動してみる

adb shell am start \
          -a android.intent.action.VIEW \
          -n com.android.chrome/com.google.android.apps.chrome.Main \
          -d http://m.yahoo.co.jp/

【オプション説明】

-a <暗黙的Intent> (android.intent.action.VIEWは、ブラウザ起動)
-n <起動したいアプリケーションのパッケージ名>/.<Activity名>>
-d <起動したいURL>

データ削除

adb shell pm clear com.android.chrome

強制終了

adb shell am force-stop com.android.chrome

アプリのパッケージ一覧を取得する方法

adb shell pm list packages

Activityスタックの状態をダンプして確認する方法

adb shell dumpsys activity activities

→ インストールしたアプリのアクティビティ名が知りたい場合などに利用できます

【補足】

androidのバージョンによって利用できないコマンドやオプションがあるのに注意しましょう!

84
74
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
84
74