SDKを入れる
android 端末を接続
- android本体の「アプリケーション」から、「開発」の中の「USBデバッグ」のチェックを選択
- USBケーブルで、androidを接続
adb shell を起動
ディレクトリ platform-tools の adb をターミナルで実行します。
android-sdk-linux_x86/platform-tools$ sudo ./adb start-server
android-sdk-linux_x86/platform-tools$ ./adb shell
adb server は必ず root 実行すること。
$ adb shell
error: insufficient permissions for device
などエラーが出たら、一旦サーバーを kill して再度起動します。
adb serverの停止は kill-server オプションをつけます。
android-sdk-linux_x86/platform-tools$ ./adb kill-server
メインメニューに登録
いちいちターミナルを開くのが面倒臭いので、メインメニューに登録します
- システム > 設定 > メインメニュー > 新しいアイテム
- 「種類」を「端末内で起動する」、「名前」は適当、「コマンド」は「adb」のフルパスと「 shell」
「コマンド」欄の例)
/opt/android-sdk-linux_x86/platform-tools/adb shell
adb shell の使い方
Android の shell はビルトインコマンドが少ないので工夫が必要
$ cat source_file > dest_file
grepは用意されていないので、母艦PC側で工夫する。(苦
android-sdk-linux_x86/platform-tools$ ./adb shell ps | grep twidroid
app_122 2259 1225 141604 41480 ffffffff 00000000 S com.twidroid
app_122 3435 1225 115000 26804 ffffffff 00000000 S com.twidroid:remote
- というか root をとって、BusyBox を入れる方がよい
adb shell で ls すると文字化けする
となってまう。そこで、
$ ls --color=never
acct init sbin
cache init.goldfish.rc sdcard
config init.herring.rc sys
とオプションをつければ元に戻る
shell 以外の adb のコマンド
1.adb push <local> <remote>
copy file/dir to device $ adb push hoge-dir /storage/sdcard0/external_sd/Music/hoge-dir
2.adb pull <remote> [<local>]
copy file/dir from device
3.adb sync [ <directory> ]
copy host-<device only if changed(-l means list but don't copy)
4.adb install APKファイル
adb install HelloWorld.apk
5.adb uninstall パッケージ名
adb uninstall net.npaka.helloworld
Thanks to
最終更新:2015年11月14日 20:33