Android Studio not stopping on breakpoints in C++ code on older API

843 views
Skip to first unread message

btanguay

unread,
Nov 23, 2020, 5:46:43 PM11/23/20
to android-ndk
Hello everyone!

I do not know yet if this is a real bug or a misconfiguration issue on my part which is why I post it here. Hopefully someone can help shed some light on my issue.

General problem

I have an Android Native application that targets two different API versions: 23 (Marshmallow) and 28 (Pie). For the API 28, I have no problem debugging a hello world application when it enters the C++ code: the debugger attaches itself and stops the execution at my breakpoints. For the API 23 however, the debugger attaches itself but never stops at the breakpoints. This behavior for both APIs is consistent across emulators and real devices.

Expected behavior

I would expect the debugger to stop on breakpoints no matter the API used.

Actual behavior

For API 23 at least, the debugger ignores the breakpoints present in C++. The problem doesn't manifest itself when an emulator or real device uses a more recent API such as 28.

Versions
  • Windows 10
  • Android Studio 4.1.1
  • Gradle 6.5
  • NDK 21.1.6352462
  • CMake 3.10.2.4988404
  • Java 8.0.265-open
Emulators comparison
API 23
  • Galaxy Nexus 4.65 720x1280
  • Android 6.0 x86_64 (Marshmallow)
API 28
  • Galaxy Nexus 4.65 720x1280
  • Android 9.0 x86_64 (Pie)

The only difference here is really the operating system. Everything else including memory allocation seems to be exactly the same.

Code

The code is the same in both cases. It pretty much follows the default JNI template provided by Android. I'll post everything in any case.

Root build.gradle

Application build.gradle

CMakeList

C++ file called through JNI (this is where the breakpoints don't work!)

Reference to a repo demonstrating the problem

https://github.com/BenjaminTanguay/android-studio-breakpoint-failure

I have confirmed with a work colleague that the problem can be repeated on his environment. However, I don't know yet if the problem is environment specific (maybe it works with different versions of software), configuration specific (perhaps I made a mistake somewhere) or is a real bug in the Android tools.

If anyone can help, I would be very grateful.


Note: This post is somewhat of a copy of the stackoverflow question found here:

https://stackoverflow.com/questions/64936460/debugging-c-native-code-in-android-studio-doesnt-work-with-older-android-sdk

Alias R. Cummins

unread,
Nov 29, 2020, 7:07:25 PM11/29/20
to andro...@googlegroups.com
Is your IDE connecting to ADB?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/62771b58-bef7-43d7-9722-74170d1ea9fcn%40googlegroups.com.

btanguay

unread,
Jan 20, 2021, 5:54:20 PM1/20/21
to android-ndk
I'm necroing an old thread to comment on a workaround that works for us. Setting API 21 instead of 23 as the minimum seems to allow us to stop on breakpoints in the native code. Not sure where the bug lies on that one but this solution works for us.

Alias R. Cummins

unread,
Jun 8, 2021, 10:20:50 PM6/8/21
to andro...@googlegroups.com
That makes sense because there was a shift between NDKs from 21 onwards.

enh

unread,
Jun 9, 2021, 12:12:15 PM6/9/21
to android-ndk
NDK r21 and API level 21 are unrelated.

i do know that Studio has a lot of heuristics about how best to debug on different releases, so Studio choosing a different path might make sense ... except it's my understanding that they look at the actual API level of the connected device rather than the target API level of the app.

regardless, issues with debugging in Studio is a bug to report to Studio directly.

Reply all
Reply to author
Forward
0 new messages