LoginSignup
4
2

More than 1 year has passed since last update.

adbで「adb.exe: more than one device/emulator」が出るとき

Last updated at Posted at 2022-06-24

複数のAndroidがPCに接続されてたりエミュレータが立ち上がってるとき

PS C:\Users\frieren> adb devices
List of devices attached
192.168.1.8:39333       device
emulator-5554   device

そのままadb shellするとエラーが出る

PS C:\Users\frieren> adb shell
adb.exe: more than one device/emulator

こういうときはadb -t 1 shellみたいにデバイスを指定する。
デバイスを指定するためのオプションはshellの前に書かないと働かないので注意。

USB接続のデバイスを指定: adb -d shell

use USB device (error if multiple devices connected)

複数台あるとエラー。

TCP/IP接続のデバイスを指定: adb -e shell

use TCP/IP device (error if multiple TCP/IP devices available)

複数台あるとエラー。
エミュレータも含まれるみたい。

Transport IDで指定: adb -t 1 shell

use device with given transport id

Transport IDはadb devices -lで確認できる。

PS C:\Users\frieren> adb devices -l
List of devices attached
192.168.1.8:39333      device product:crosshatch model:Pixel_3_XL device:crosshatch transport_id:2
emulator-5554          device product:sdk_gphone64_x86_64 model:sdk_gphone64_x86_64 device:emu64xa transport_id:1

シリアルで指定: adb -s XXXXX shell

use device with given serial (overrides $ANDROID_SERIAL)

シリアルといってもデバイスのシリアル番号のことじゃない。紛らわしい。
adb devicesの最初に出てるデバイス名みたいなもののこと。

シリアルだけじゃなくて上記だとadb -s product:crosshatch shellみたいにやっても接続できたり、ほかにも接続できる書き方はあるっぽい。

オプションじゃなく環境変数で指定

ANDROID_SERIALに上記シリアルを書き込むとずっと使ってくれるらしい。

windows(powershell)で一時的に指定したいとき
$env:ANDROID_SERIAL = "emulator-5554"
windows(powershell)でずっと指定したいとき
[Environment]::SetEnvironmentVariable("ANDROID_SERIAL", "emulator-5554", "User")

windows以外のやり方は誰でも分かるので書きません

参考URL


ググったらエミュレータ終了しようとか出るけど選択できないわけないでしょって思って調べました。
昔はなかったのかも?

4
2
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
4
2