1

flutter run -d <deviceId> allows running the app on a specific device.

Emulators have device id as emulator-5554, emulator-5556 and so on. Thus I can specify the emulator to use, using flutter run -d emulator-5554

When I connect two physical devices, a phone, and a tablet and run adb devices -l I get the same device id for both devices. Thus, Flutter cannot run on both devices simultaneously.

deviceIds

As you can see one is a phone LS 5020 and the other is a tablet P702 but the device id is the same. The same is found on both Windows 10 and Linux Mint 19.2


Is there a way to fix this using any other command to specify the device to use or somehow change the device id?

EDIT: output of flutter devices flutter devices

1 connected device:

0123456789ABCDEF • 0123456789ABCDEF • android-arm64 • Android 6.0 (API 23)

Also, flutter run -d all runs the app on one of these devices

Output of flutter devices -v

[  +44 ms] executing: /home/droid/androidSdkUbuntu/platform-tools/adb devices -l
[  +13 ms] Exit code 0 from: /home/droid/androidSdkUbuntu/platform-tools/adb devices -l
[        ] List of devices attached
           0123456789ABCDEF       no permissions (user in plugdev group; are your udev rules wrong?); see [http://developer.android.com/tools/device.html] usb:1-3 transport_id:16
           0123456789ABCDEF       device usb:3-2 product:LS-5020 model:LS_5020 device:LS-5020 transport_id:12
[  +22 ms] 1 connected device:

[   +3 ms] /home/droid/androidSdkUbuntu/platform-tools/adb -s 0123456789ABCDEF shell getprop
[  +70 ms] ro.hardware = mt6735
[        ] ro.build.characteristics = default
[   +3 ms] 0123456789ABCDEF • 0123456789ABCDEF • android-arm64 • Android 6.0 (API 23)
Doc
  • 10,831
  • 3
  • 39
  • 63
  • does `flutter devices` show the same? – pskink Jan 05 '20 at 17:45
  • Posted the output. – Doc Jan 05 '20 at 19:56
  • `-h` gives nothing except info about command. `adb` is default provided by android studio – Doc Jan 05 '20 at 20:49
  • `adb --version` gives `Android Debug Bridge version 1.0.41 Version 29.0.5-5949299` – Doc Jan 05 '20 at 20:51
  • `flutter devices -h` `List all connected devices. Usage: flutter devices [arguments] -h, --help Print this usage information. Run "flutter help" to see global options.` – Doc Jan 05 '20 at 20:52
  • sorry i mean `flutter devices -v`, not `-h` - it will show the full `adb` command – pskink Jan 05 '20 at 20:53
  • check edit in answer – Doc Jan 05 '20 at 20:56
  • check last 12 lines - sterting from: `/home/droid/androidSdkUbuntu/platform-tools/adb devices -l [ ]` – pskink Jan 05 '20 at 20:58
  • posted in the question edit – Doc Jan 05 '20 at 21:05
  • I have run the command `flutter devices -v` in some cases and the final result is posted with both devices connected. When both devices are connected `flutter run -d all` runs only on phone in all cases. When devices are used separately both work fine on their own. Looks like flutter is running the command on the first device and the phone is always listed first. Also, it says only one device is connected due to the same device id. Can I change the device id? Or use any other parameter like `device usb`,`product`, `model`, `device` or `transport_id` as they are different for both? – Doc Jan 05 '20 at 21:32
  • did you notice: `0123456789ABCDEF no permissions (user in plugdev group; are your udev rules wrong?); see [http://developer.android.com/tools/device.html] usb:1-3 transport_id:16` ? tried to fix that? – pskink Jan 06 '20 at 07:10
  • Yes, I have checked that. If USB tethering is OFF for the tablet then the issue is not shown. But the app does not run without tethering set to ON. So, even though it shows error it runs fine. – Doc Jan 06 '20 at 08:16

2 Answers2

2

Give flutter run -d all a try.

MickaelHrndz
  • 3,604
  • 1
  • 13
  • 23
  • I was hoping to run via Android Studio config rather than command-line version but will check this. – Doc Jan 05 '20 at 19:01
  • tested; runs only on 1 device and not both. – Doc Jan 05 '20 at 19:12
  • That's weird. To be clear, the apps are built and launched one after another, not at the same time. You can also use their names (P702 & LS-5020) but I don't think you can include multiple devices in one command. By the way, you can [create a configuration](https://stackoverflow.com/a/54532722/3925977) for that command. – MickaelHrndz Jan 06 '20 at 05:55
  • can you give me an example of a command to run using their name? I run using the command `flutter run -d ` which is the main issue here. – Doc Jan 06 '20 at 08:14
  • Device id and name are interchangeable here. So it would be `flutter run -d P702` and `flutter run -d LS-5020` – MickaelHrndz Jan 06 '20 at 08:17
  • Running with name works for tablet separately; not working for the phone in any case(using only device id works). When both are connected and config is run for the tablet using its name, it fails as it uses `deviceId` under the hood for the command. It looks like using the name of the device is provided as a handy shortcut for not typing the deviceId. – Doc Jan 06 '20 at 15:44
0

Open your terminal and type flutter run it will ask you to pick the device you want to use and do that by simply picking the numbered device of choice

Kipruto
  • 721
  • 6
  • 16