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?
flutter -v -d your_android_device run selects the target device to run on.
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>.
flutter -d 54XXXXXX35130ebefd38f run
Related
I couldn't install flutter app on my android phone. How can I do it? I can run by usb debugging However I want to install it on my phone. Can someone help me please?
If you use IntelliJ Idea (it should also work on Android Studio), you can go to
Build -> Flutter -> Build APK, (in the menu bar)
and after building, your apk will appear in
build/app/outputs/flutter-apk/app-release.apk,
just send the file to your phone and install, your phone will probably tell you not do download cause it isn't checked and secured or something, just ignore and install anyway
Connect your Android device to your computer with a USB cable.
Enter cd [project].
Run flutter install.
Source: here
You need to build the app to get the apk. For building apk use this command in console: flutter build apk and if you want to build your apk in smaller size then use this command in console: flutter build apk --split-per-abi.
After building apk you will find it in [project]\build\app\outputs\flutter-apk\app-armeabi-v7a-release.apk here.
If you don't want to build apk and just want to test your app you can run it in profile mode by using this command in console: flutter run --profile.
In android studio under the tools-> build -> build apk will create and app for you and you can get and the output location will show you after the builing the app
Flutter 3.0 is amazing !!
I can make a web app, android & iOS mobile app, and a native Mac app (and more) all from the one code base.
But now my problem is :
How do I specify which OS to build-for and run-on ?
When I do flutter run or debug>run in VSCode it will build-for, and run-on, my Android device first if it plugged in, or else as a Mac app. I want to run it as Web. More generally, I want to specify which OS I want to build and run for.
Both the flutter run command line option, and the VSCode setting (preferably without messing about with launch.json, or else making that seem easy).
You can use
flutter run -d chrome
For running it on chrome
flutter run -d your_device
For mobile device
It depends on the selected device. If you select an Android Device, it will build for Android OS. If you select a browser then it will run the build on your Default Browser and the same goes for other scenarios.
I installed the flutter and dart plugins on Android Studio, already installed SDK and AVD for the Android emulator. But the program still runs on chrome
If you are using VS Code, you can select the target device by using the status bar changer:
That will open up the list of connected devices in the command palette you can pick from.
Launch your Android emulator, run flutter devices to get the id of the emulator device. Then, you can run flutter run -d [emulator_id] to launch the Flutter application on the targeted device.
To see available emulators run this command:
flutter emulators
Then copy the name of emulator from there and enter this command:
flutter emulators --launch EmulatorNameHere
Now when the emulator ready and running:
flutter run
I want to run flutter app in VS.Code without android studio emulator.
I want run my app without install android studio.
How can I do this?
If you have Gradle properly installed globally (https://gradle.org/install/) and the Android SDK setup on your machine, then you should not need the IDE.
Try first checking for available devices:
flutter devices
Then using the device that you find (if there are any spaces in the name that represents the device then use "" to format the command), execute the following command:
flutter run -d "Device Name With Spaces" --release
Or:
flutter run -d DeviceNameWithoutSpaces --release
The first option is You can run your application on chrome or edge if you don't want to download an emulator. Follow the following steps:
Click on the no-device option to select the device.
Now select chrome or edge
And the second option is you can connect your mobile with your PC and use your phone to run the flutter apps. Follow the following steps:
For Android:
Enable developer options and USB Debugging on your device. This varies slightly
by android version. But the short version is you tap on the device build number
7 times.
Then a “Developer Options” option comes up. After that, you can click “enable
USB Debugging.”
Then plug your phone into your computer with a USB cable. You’ll see some popup
on your phone asking if you want to allow USB debugging with that computer.
Click on “yes”.
Run Flutter just like you would if you had a simulator running.
I have created a web app using Flutter and it is running fine.
I wanted to create a mobile app out of it with as little modification to the code as possible and wanted to run it in an Android Emulator, so I installed Android Studio and then a device in ADV Manager. The code did not show any errors but Android Studio is not able to locate the newly installed device. Am I missing something?
The question could also be reframed as: how to convert a Flutter web app into a mobile app.
Source of this answer is :here
Can you try to run the below command in terminal:
flutter devices
Does it show something like this?
Android SDK built for x86 (mobile)
If not, then try to run the following commands:
flutter config --android-sdk <path to android sdk>
flutter config --android-studio-dir <path to android studio>
Replace with the actual path to the SDK in your machine.
And then restart your Android Studio. You should see your virtual device listed under Flutter Device Selection.
Please note, to find the path to Android SDK, you can go to Preferences as shown in this image