5

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?

TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
  • 2
    what does `flutter devices` command show? – pskink Dec 29 '20 at 11:29
  • 1
    `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. – TheWaterProgrammer Dec 29 '20 at 11:32
  • 1
    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. – TheWaterProgrammer Dec 29 '20 at 11:33
  • 2
    `flutter -v -d your_android_device run` (`-v` is optional: it stands for "verbose") – pskink Dec 29 '20 at 11:34

3 Answers3

12

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

TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
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>.

rgisi
  • 858
  • 6
  • 21
0

flutter -d 54XXXXXX35130ebefd38f run

  • 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](https://stackoverflow.com/help/privileges/vote-up) once you have enough [reputation](https://stackoverflow.com/help/whats-reputation) – lepsch Sep 06 '22 at 08:16