How to `flutter run` with target device as android?
Asked Answered
W

3

11

I have my flutter app built and running on macOS using the following command.

flutter run

This is great.
Now, I want to run my app on an Android device. It has developer mode enabled and getting recognised when I run adb devices. I have also run other apps on my Android device. So, I am sure the android device is well set for android development.

But now when execute flutter run, my app still runs on macOS instead of Android device. I did a flutter build apk which built my app for android. But, flutter run still runs on Mac instead of Android.

Isn't there a flutter run command to run the build on Android specifically?

Weeden answered 29/12, 2020 at 11:26 Comment(4)
what does flutter devices command show?Philis
flutter devices showed that my device was not authorised. This was stupid. I had it authorised for multiple other run sessions. But, your suggestion got me to find the root cause of my problem. Please feel free to post an answer and I can accept it.Weeden
Additionally, if there is a command to select flutter run's target as Android, I would like to know that. That was my original question as well.Weeden
flutter -v -d your_android_device run (-v is optional: it stands for "verbose")Philis
W
20

flutter -v -d your_android_device run selects the target device to run on.

Weeden answered 29/12, 2020 at 11:36 Comment(4)
btw you dont have to pass the whole device_id - you can shorten it to few lettersPhilis
Ah. Thats even better!Weeden
actually i checked that even one letter is enough (if it selects one device of course) ;-)Philis
The device id can be found by the command flutter devices, iti is the second column in the listBridging
V
7

Check that your device is recognized using flutter devices (or flutter doctor -v). If so, you can specify the device id you using flutter run -d <deviceID>.

Vignola answered 29/12, 2020 at 11:33 Comment(0)
D
1

flutter -d 54XXXXXX35130ebefd38f run

Doxia answered 31/8, 2022 at 20:2 Comment(1)
Welcome to SO! Though we thank you for your answer, it would be better if it provided additional value on top of the other answers. In this case, your answer does not provide additional value, since another user already posted that solution. If a previous answer was helpful to you, you should vote it up once you have enough reputationPettitoes

© 2022 - 2024 — McMap. All rights reserved.