How to `flutter run` with target device as android?
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>
.
TheWaterProgrammer
#include <AlwaysAStudent> int main(int argc, char *argv[]) { std::thread always_keep_learning([&] { Learn(); }); always_keep_learning.detach(); return 0; }
Updated on December 01, 2022Comments
-
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 runadb 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 aflutter 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 over 3 yearswhat does
flutter devices
command show? -
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 over 3 yearsAdditionally, 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 over 3 years
flutter -v -d your_android_device run
(-v
is optional: it stands for "verbose")
-
-
pskink over 3 yearsbtw you dont have to pass the whole device_id - you can shorten it to few letters
-
TheWaterProgrammer over 3 yearsAh. Thats even better!
-
pskink over 3 yearsactually i checked that even one letter is enough (if it selects one device of course) ;-)
-
Jurgen De Jonghe over 2 yearsThe device id can be found by the command flutter devices, iti is the second column in the list