Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug native Android invoked from Flutter Pllatform Channel

I can't seem to figure out how to make debugging work for a native Android module invoked from a Flutter app via a Platform Channel. I'm using the sample from the Flutter documentation (https://flutter.dev/docs/development/platform-integration/platform-channels). I've tried the following:

  1. Open the Flutter project in IntelliJ
  2. Right click the android folder and select Flutter | Open Android Module in Android Studio
  3. Android Studio opens the native Android code.
  4. Set breakpoints in Android code
  5. Click Debug from Android Studio
  6. Emulator shows "Waiting for Debugger Application is waiting for deubgger to attach" while in Android Studio the debug console shows 'Connected to the target VM, address: 'localhost:8601''
  7. Run Flutter App from IntelliJ (I've also tried Debug from IntelliJ - flutter code will stop on breakpoints)
  8. The breakpoints fro the native Android code never breaks

What am I doing wrong?

like image 358
Ken Avatar asked Dec 09 '25 12:12

Ken


1 Answers

I started another project and was able to get it working.

To debug the Flutter code, start the debugger from IntelliJ

To debug the native android code, right click on the android folder and select Flutter | Open Android Module in Android Studio. Start the debugger there. The Flutter app will open in the emulator and you can set/hit breakpoints in the native code

like image 112
Ken Avatar answered Dec 12 '25 02:12

Ken



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!