text
stringlengths
1
474
If you want to use the GNU Project Debugger to debug the
Flutter engine running within an Android app process,
check out flutter_gdb.<topic_end>
<topic_start>Build the Android version of the Flutter app in the Terminal
To generate the needed Android platform dependencies,
run the flutter build command.<topic_end>
<topic_start>Start debugging with VS Code first
If you use VS Code to debug most of your code, start with this section.To open the Flutter app directory, go to
File >
Open Folder… and choose the my_app directory.Open the lib/main.dart file.If you can build an app for more than one device,
you must select the device first.Go to
View >
Command Palette…You can also press Ctrl / Cmd +
Shift + P.Type flutter select.Click the Flutter: Select Device command.Choose your target device.Click the debug icon
().
This opens the Debug pane and launches the app.
Wait for the app to launch on the device and for the debug pane to
indicate Connected.
The debugger takes longer to launch the first time.
Subsequent launches start faster.This Flutter app contains two buttons:<topic_end>
<topic_start>Attach to the Flutter process in Android Studio
Click the Attach debugger to Android process button.
()lightbulb Tip
If this button doesn’t appear in the Projects menu bar, verify that
you opened Flutter application project but not a Flutter plugin.The process dialog displays one entry for each connected device.
Select show all processes to display available processes for each
device.Choose the process to which you want to attach.
For this guide, select the com.example.my_app process
using the Emulator Pixel_5_API_33.Locate the tab for Android Debugger in the Debug pane.In the Project pane, expand
my_app_android >
android >
app >
src >
main >
java >
io.flutter plugins.Double click GeneratedProjectRegistrant to open the
Java code in the Edit pane.At the end of this procedure, both the Dart and Android debuggers interact
with the same process.
Use either, or both, to set breakpoints, examine stack, resume execution
and the like. In other words, debug!<topic_end>
<topic_start>Start debugging with Android Studio first
If you use Android Studio to debug most of your code, start with this section.To open the Flutter app directory, go to
File >
Open… and choose the my_app directory.Open the lib/main.dart file.Choose a virtual Android device.
Go to the toolbar, open the leftmost dropdown menu, and click on
Open Android Emulator: <device>.You can choose any installed emulator that’s doesn’t include arm64.From that same menu, select the virtual Android device.From the toolbar, click Run ‘main.dart’.You can also press Ctrl + Shift + R.After the app displays in the emulator, continue to the next step.Click the Attach debugger to Android process button.
()lightbulb Tip
If this button doesn’t appear in the Projects menu bar, verify that
you opened Flutter application project but not a Flutter plugin.The process dialog displays one entry for each connected device.
Select show all processes to display available processes for each
device.Choose the process to which you want to attach.
For this guide, select the com.example.my_app process
using the Emulator Pixel_5_API_33.Locate the tab for Android Debugger in the Debug pane.In the Project pane, expand
my_app_android >
android >
app >
src >
main >
java >
io.flutter plugins.Double click GeneratedProjectRegistrant to open the
Java code in the Edit pane.At the end of this procedure, both the Dart and Android debuggers interact
with the same process.
Use either, or both, to set breakpoints, examine stack, resume execution
and the like. In other words, debug!<topic_end>
<topic_start>
Debug Dart and iOS code using Xcode
To debug iOS code, you need a Flutter app that contains iOS code.
In this section, you learn to connect two debuggers to your app:
Flutter via VS Code and Xcode. You need to run both VS Code and Xcode.These section uses the same example Flutter url_launcher app created
in Update test Flutter app.<topic_end>
<topic_start>Build the iOS version of the Flutter app in the Terminal
To generate the needed iOS platform dependencies,
run the flutter build command.<topic_end>
<topic_start>Start debugging with VS Code first
If you use VS Code to debug most of your code, start with this section.<topic_end>
<topic_start>Start the Dart debugger in VS Code
To open the Flutter app directory, go to
File >
Open Folder… and choose the my_app directory.Open the lib/main.dart file.If you can build an app for more than one device,
you must select the device first.Go to
View >
Command Palette…You can also press Ctrl / Cmd +
Shift + P.Type flutter select.Click the Flutter: Select Device command.Choose your target device.Click the debug icon
().
This opens the Debug pane and launches the app.
Wait for the app to launch on the device and for the debug pane to
indicate Connected.
The debugger takes longer to launch the first time.
Subsequent launches start faster.This Flutter app contains two buttons:<topic_end>
<topic_start>Attach to the Flutter process in Xcode
To attach to the Flutter app, go to
Debug >
Attach to Process >
Runner.Runner should be at the top of the Attach to Process menu
under the Likely Targets heading.<topic_end>
<topic_start>Start debugging with Xcode first
If you use Xcode to debug most of your code, start with this section.<topic_end>
<topic_start>Start the Xcode debugger
Open ios/Runner.xcworkspace from your Flutter app directory.Select the correct device using the Scheme menu in the toolbar.If you have no preference, choose iPhone Pro 14.Run this Runner as a normal app in Xcode.When the run completes, the Debug area at the bottom of Xcode displays
a message with the Dart VM service URI. It resembles the following response:Copy the Dart VM service URI.<topic_end>