How Do I Run/test My Flutter App On A Real Device?
Solution 1:
For Android, this is pretty easy:
- 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.
- 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".
- 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":
- Open XCode, then open "Preferences>Accounts". Sign in with your ID.
- "Manage Certificates" > click on the "+" sign and select "iOS Development".
- Plug your device into your machine. Find your device in the drop down (Window > Organizer).
- Below the Team pop-up menu, click Fix Issue.
- 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.)
Solution 2:
Also you can use your 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.
Make sure your phone is connected to your PC/Laptop.
Enable Developers Options and Connect your device to the WIFI.
Open CMD.
Input "adb tcpip 5555". The adb should be restarted
Next, input "adb connect ipaddressofyourdevice:5555" Ex: adb connect 192.168.254.19:5555
Now, you can use your device wirelessly.
Solution 3:
Deploy to iOS devices
To deploy your Flutter app to a physical iOS device, you’ll need some additional tools and an Apple account. You’ll also need to set up physical device deployment in Xcode.
Install homebrew.
Open the terminal and run these commands to install the tools for deploying Flutter apps to iOS devices.
$ brew update $ brew install --HEAD libimobiledevice $ brew install ideviceinstaller ios-deploy cocoapods $ pod setup
If any of these commands fails with an error, run brew doctor and follow the instructions for resolving the issue.
Follow the Xcode signing flow to provision your project: Open the default Xcode workspace in your project by running open
ios/Runner.xcworkspace
in a terminal window from your Flutter project directory.In Xcode, select the Runner project in the left navigation panel.
In the Runner target settings page, make sure your Development Team is selected under
General > Signing > Team
. When you select a team, Xcode creates and downloads a Development Certificate, registers your device with your account, and creates and downloads a provisioning profile (if needed).- To start your first iOS development project, you may need to sign into Xcode with your Apple ID.
Development and testing is supported for any Apple ID. Enrolling in the Apple Developer Program is required to distribute your app to the App Store. To create an Apple ID, follow the instructions on the Apple help page.
- The first time you use an attached physical device for iOS development, you will need to trust both your Mac and the Development Certificate on that device. Select Trust in the dialog prompt when first connecting the iOS device to your Mac.
Then, go to the Settings app on the iOS device,
select General > Device Management
and trust your Certificate.If automatic signing fails in Xcode, verify that the project’s
General > Identity > Bundle Identifier
value is unique.Start your app by running
flutter run
For more info: https://kobiton.com/topics/develop-deploy-and-test-flutter-apps/
Post a Comment for "How Do I Run/test My Flutter App On A Real Device?"