问题
I am developing a package in C++ to be used in a Flutter app (and therefore in Dart), using dart::ffi and I was wondering if there was a better way to debug (step by step, variable watch, that sort of things) the C++ code, other than logging messages. I've tried both in Android Studio and VS Code, with no success.
回答1:
Android Studio (or VS Code) doesn't support native (C/C++) code debugging while in Flutter mode (yet). However, there is a workaround! In the project tree, right-click the 'android' folder and select Flutter -> Open Android module in Android Studio. The project will switch to Android development mode where c/c++ debugging is fully supported. Now just search for the 'cpp' folder, set breakpoints in any of the files there and run the app (while still in the Android development mode of course)!
来源:https://stackoverflow.com/questions/62351258/debug-c-code-from-dart-package-using-dartffi