Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run/test my Flutter app on a real device?

I want to run/test (not automated test) my Flutter app on a real iPhone and Android phone during development. However, Flutter docs seem to only document how to do it with the iOS simulator or Android emulators.

I think it's already a no-brainer for iOS/Android devs but I am neither and Flutter is my first foray into mobile development.

Is there any link to a beginner's guide somewhere on how to develop while running it on a real device (with all of Flutter's live-reload goodness)?

Additional context

  • I'm a web developer.
  • I use Android Studio and VS Code.
  • I work on a MacBook.
like image 310
Noel Llevares Avatar asked Jan 30 '19 15:01

Noel Llevares


People also ask

How do you test the Flutter app on physical device?

Set up and deploy Flutter apps on your Android device Using a USB cable, plug your phone into your computer. If prompted on your device, authorize your computer to access your device. In the terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device.

How do I run a Flutter on a specific device?

If you have multiple devices or simulators connected then there are a number of ways to quickly switch between them: Clicking on the currently selected device in the status bar. Executing the Flutter: Select Device command. Pressing your custom key binding for the Flutter: Select Device command.

How do I run the Flutter app on real IOS?

To test or deploy our flutter app to a physical device we first need to enable physical device deployment in Xcode using Apple ID or an Apple Developer account. And we also need to set up a package manager to manage flutter plugins that are to be used in the project.


2 Answers

For Android, this is pretty easy:

  1. 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 and you can click "enable USB Debugging." See the linked Android documentation for the most up-to-date instructions.
  2. Then plug your phone into your computer with a USB cable. You'll probably see some popup on your phone asking if you want to allow USB debuggng with that computer. Say "yes".
  3. Run Flutter just like you would if you had a simulator running.

For iOS this is a little more complicated because you need an Apple ID or to sign up for a "Developer Account":

  1. Open XCode, then open "Preferences>Accounts". Sign in with your ID.
  2. "Manage Certificates" > click on the "+" sign and select "iOS Development".
  3. Plug your device into your machine. Find your device in the drop down (Window > Organizer).
  4. Below the Team pop-up menu, click Fix Issue.
  5. In Xcode, click the Run button.

(in subsequent runs, you can deploy to the iOS device with Android Studio, VS Code, or any other IDE of choice, you just need to set up that certificate the first time with Xcode. Here's Apple's documentation on setting up Xcode to run a physical device.)

like image 155
fortuna Avatar answered Sep 25 '22 02:09

fortuna


Also, you can use your android device wirelessly using scrcpy.

Visit this link and install scrcpy. https://github.com/Genymobile/scrcpy

After you install and path scrcpy on your PC/Laptop.

  1. Make sure your phone is connected to your PC/Laptop.

  2. Enable Developers Options and Connect your device to the WIFI.

  3. Open CMD.

  4. Input "adb tcpip 5555". The adb should be restarted

  5. Next, input "adb connect ipaddressofyourdevice:5555" Ex: adb connect 192.168.254.19:5555

Now, you can use your device wirelessly.

like image 25
Miguel Rosal Avatar answered Sep 26 '22 02:09

Miguel Rosal