How to debug native Android invoked from Flutter Pllatform Channel - android

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:
Open the Flutter project in IntelliJ
Right click the android folder and select Flutter | Open Android Module in Android Studio
Android Studio opens the native Android code.
Set breakpoints in Android code
Click Debug from Android Studio
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''
Run Flutter App from IntelliJ (I've also tried Debug from IntelliJ - flutter code will stop on breakpoints)
The breakpoints fro the native Android code never breaks
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

What worked for me was running the app in debug mode in Android Studio and then pressing the "Attach Debugger to Android Process" button.

Related

Debugging the Android project in my flutter app results in no app being launched and no debugger being connected

I have a flutter app that I normally develop using Visual Studio Code.
I have a small amount of code in my MainActivity.kt that I want to debug.
I have opened the 'android' folder in my flutter project with Android Studio. I have then added some breakpoints to MainActivity.kt, and hit the debug start button.
There is a green tooltip that pops up that says 'launch succeeded', but no app launches on my device, and none of my breakpoints hit.
EDIT: The debug output says...
Waiting for application to come online: com.me.myapp
Could not connect to remote process. Aborting debug session.
How can I debug my MainActivity.kt?

Android Studio Windows: Debugger process finished with exit code -1073741515 (0xC0000135)

I have both native code and Java in my app so I need to be able to debug both Java and native code.
After upgrading to Android Studio Bumblebee | 2021.1.1 Patch 2, I can no longer debug my app with native debugging enabled. If the 'Debug type:' is set to Java Only, I can run in debug mode and trace through Java code but cannot trace into native functions. If 'Debug type:' is set to Detect Automatically, Native Only or Dual (Java+Native) the debugger fails to start.
I never had trouble debugging native code before. When I try to start in debug mode I get the following error:
Debugger process finished with exit code -1073741515 (0xC0000135). A library required by the native debugger might be missing on your system.
How do I find out what library is missing? I upgraded everything that Android Studio said had updates.
Go to "Run->Edit Configurations" then select the "Debugger" menu item and check to see if "Debug type" was set to "Detect Automatically". If so, try setting it to "Java Only", apply that and see if the debugger now works. That's what fixed it for me.

How do I get Visual Studio to debug an Android app?

I'm using Visual Studio 2017 to build and deploy a NativeActivity to my Android device. It builds and deploys with no issues, but I cannot set breakpoints.
Before running, I can add a breakpoint to a line (the first line of android_main() for example) and the little red circle shows up on the left of that line in the IDE as you'd expect.
But after installing and running the app, the breakpoint doesn't trigger because the red circle has turned white - it's saying there are no debug symbols.
I've verified I'm building the Debug version and have verified the APK file is bigger and has the debug symbols by using Android Studio.
At this point it appears to me that Visual Studio itself is confused and somehow doesn't recognize the debug symbols.
I've added "-g" to the C++ options manually, and have added the Gradle line packagingOptions.doNotStrip '**.so' as well. But still this problem persists.
What would cause this behavior in Visual Studio and how can I fix it?
The Xamarin debugger can only debug managed (i.e. C#) code. Breakpoints only work with the Xamarin debugger if the project being debugged is a managed project. They don't work if the project is a native app or native library.
So you have to make NativeActivity c++ app be attached to a Xamarin Managed App(Acttach to Process)to get what you want.
1) create a c# xamarin android app and then input that xamarin managed apk file into the NativeActivity c++ app's Properties-->Debugging-->Package To Launch
2) start Xamarin c# app first and then make the Xamarin debugger active. While the managed app is still running or being debugged, right-click on the native library project and select Debug --> Attach to Android process.
Here is an example provided by Richard Walters and he provided the detailed info.

Debug React Native App from Visual studio Emulator for Android

I am running my React Native app in Visual Studio Emulator for Android. Can someone tell me how can i debug my js code ? In Android studio simulator we have options to remote debug. But from Visual studio Emulator how can i debug..Thanks in Advance.
If you have chrome installed, then you can use the chrome debugger to debug your js code.
First
Mac: command + M
Window: control + M
Then click debug js remotely; It will open a tab in chrome, then right click and select inspect, switch to the console tab. Any statement you console will appear there.
There are two ways you can debug your code.
First one : Using visual studio debug menu.
Press ctrl+shift+D to open up debug menu and select Attach to Packager or select 4th item on the left in visual studio.
This allows you to set break points and debug code as you see in Android Studio.
Second one : Using React Native Debugger

Can't debug NDK samples with Android Studio 1.3.2 on Windows

I have Android Studio 1.3.2, NDK r10e, gradle experimental plugin 0.2.0. I have cloned the ndk samples repo and carefully followed instructions for the NDK Preview, including creating a Native configuration.
When I select LLDB as the debugger and debug the Teapot NDK sample app (breakpoint in TeapotNativeActivity.cpp, line 393), the app runs, but breakpoint isn't hit as it should when I rotate the teapot. Using GDB for the debugger results in the app freezing on startup. I then have to force quit the app and press stop in the debugger window.
In both cases, debug controls appear (greyed out), and the variables window says, "Connecting", but I never see the "Waiting for Debugger" dialog on my device.
Console output using LLDB:
Console output using GDB:
Now, when I do the same thing from Android Studio 1.4 Preview 3, I now get the "Waiting for Debugger" dialog, but it hangs there. It looks like the debugger never connects.
Console output Android Studio 1.4:
Is it possible to debug with AS 1.3.2 or 1.4? What do I need to do next to get it working?
I upgraded to Android Studio 1.4 beta and the issue is fixed. I can now debug my C++ code.

Categories

Resources