[英]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.我似乎无法弄清楚如何对通过平台通道从 Flutter 应用程序调用的本机 Android 模块进行调试。 I'm using the sample from the Flutter documentation ( https://flutter.dev/docs/development/platform-integration/platform-channels ).
我正在使用 Flutter 文档( 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要调试 Flutter 代码,请从 IntelliJ 启动调试器
To debug the native android code, right click on the android folder and select Flutter |要调试原生 android 代码,请右键单击 android 文件夹和 select ZC047B10EEE7631CC26164E07ZCF Open Android Module in Android Studio.
在 Android Studio 中打开 Android 模块。 Start the debugger there.
在那里启动调试器。 The Flutter app will open in the emulator and you can set/hit breakpoints in the native code
Flutter 应用程序将在模拟器中打开,您可以在本机代码中设置/命中断点
Flutter has a problem with debugging if you use relative paths. Flutter如果使用相对路径调试有问题。 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.
在 flutter 中以这种方式导入语句是一个好习惯。
What worked for me was running the app in debug mode in Android Studio and then pressing the "Attach Debugger to Android Process" button.对我有用的是在 Android Studio 中以调试模式运行应用程序,然后按下“将调试器附加到 Android 进程”按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.