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:
What am I doing wrong?
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
Flutter has a problem with debugging if you use relative paths. For example, if your import statements look like the following, debugging won't work
import '../app.dart';
Change these statements to
import 'package:your_package/app.dart';
The debugger will begin to work after that. It's a good habit in flutter to import the statements in this manner.
What worked for me was running the app in debug mode in Android Studio and then pressing the "Attach Debugger to Android Process" button.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.