Debug C++ code from Dart package using dart::ffi

Issue

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.

Solution

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)!

Answered By – RayX

Answer Checked By – Marilyn (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *