How to `flutter run` with target device as android?

1,864

Solution 1

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

Solution 2

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>.

Share:
1,864
TheWaterProgrammer
Author by

TheWaterProgrammer

#include &lt;AlwaysAStudent&gt; int main(int argc, char *argv[]) { std::thread always_keep_learning([&amp;] { Learn(); }); always_keep_learning.detach(); return 0; }

Updated on December 01, 2022

Comments

  • TheWaterProgrammer
    TheWaterProgrammer over 1 year

    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?

    • pskink
      pskink over 3 years
      what does flutter devices command show?
    • TheWaterProgrammer
      TheWaterProgrammer over 3 years
      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
      TheWaterProgrammer over 3 years
      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.
    • pskink
      pskink over 3 years
      flutter -v -d your_android_device run (-v is optional: it stands for "verbose")
  • pskink
    pskink over 3 years
    btw you dont have to pass the whole device_id - you can shorten it to few letters
  • TheWaterProgrammer
    TheWaterProgrammer over 3 years
    Ah. Thats even better!
  • pskink
    pskink over 3 years
    actually i checked that even one letter is enough (if it selects one device of course) ;-)
  • Jurgen De Jonghe
    Jurgen De Jonghe over 2 years
    The device id can be found by the command flutter devices, iti is the second column in the list