LoginSignup
1
0

Android: adb の使い方

Last updated at Posted at 2023-12-07

バージョンの確認

adb version
$ adb version
Android Debug Bridge version 1.0.41
Version 34.0.5-10900879
Installed as /home/uchida/Android/Sdk/platform-tools/adb
Running on Linux 6.5.0-14-generic (x86_64)

接続しているデバイスを調べる

adb devices
$ adb devices
List of devices attached
123456789A	device

Android の shell を使う

adb -s 123456789A shell
$ adb -s 123456789A shell
rk322x_box:/ $ uname -a
Linux localhost 4.4.126 #26 SMP PREEMPT Mon Jun 12 18:03:00 +08 2023 armv7l

Android の logcat を見る

adb -s 123456789A logcat

logcat のクリア

adb -s 123456789A logcat -c

フィルター機能を使う

adb -s 123456789A logcat  -s MainActivity:*

インストールしたパッケージの確認

adb -s 123456789A shell pm list packages -3
$ adb -s 123456789A shell pm list packages -3
package:org.ekzemplaro

パッケージのインストール

adb  -s 123456789A install -r ./app-debug.apk

パッケージの削除

adb  -s 123456789A uninstall org.ekzemplaro

インストールしたパッケージの実行

adb -s 123456789A shell am start org.ekzemplaro/org.ekzemplaro.MainActivity

サービスの確認

adb -s 123456789A shell dumpsys activity service org.ekzemplaro.ServiceA

サービスが動いている時

$ adb -s 123456789A shell dumpsys activity service org.ekzemplaro.ServiceA
SERVICE org.ekzemplaro/.ServiceA ccb7eb6 pid=2385
  Client:
    nothing to dump

サービスが動いていない時

$ adb -s 123456789A shell dumpsys activity service org.ekzemplaro.ServiceA
No services match: org.ekzemplaro.ServiceA
Use -h for help.

データベース (sqlite3) へのアクセス

パッケージは、com.example.room02 とします。

$ adb -s 123456789A shell
rk322x_box:/ $ su
rk322x_box:/ # cd /data/data/com.example.room02/databases
rk322x_box:/data/data/com.example.room02/databases # sqlite3 room-sample.db
SQLite version 3.19.4 2017-08-18 19:28:12
Enter ".help" for usage hints.
sqlite> .tables
Dept               User_view          room_master_table
User               android_metadata 
sqlite> .quit
1
0
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
1
0