How can I debug C++ code in Android Studio?

359 views
Skip to first unread message

chronotext

unread,
Oct 2, 2023, 11:08:59 AM10/2/23
to android-ndk

I have a C++ project in Android Studio that crashes at some point when running on a device.

The problem is that I receive some assembly dump instead of seeing the problem in the C++ code. Setting breakpoints does not work either.

My build.gradle contains the following:

externalNativeBuild {
  cmake {
    abiFilters
"armeabi-v7a", "arm64-v8a"
    cppFlags "-std=c++14"
    arguments "-DCMAKE_BUILD_TYPE=Debug", "-DANDROID_TOOLCHAIN=gcc"
  }
}
packagingOptions {
  doNotStrip
"*/armeabi-v7a/*.so"
  doNotStrip "*/arm64-v8a/*.so"
}
buildTypes {
  customDebugType {
    debuggable
true
    minifyEnabled false
  }
}

Unfortunately, it's not helping. Did anyone successfully debugged C++ code in Android Studio?


Dan Albert

unread,
Oct 3, 2023, 5:16:00 PM10/3/23
to andro...@googlegroups.com
You'll probably have better luck filing a bug against Android Studio.

"-DANDROID_TOOLCHAIN=gcc"

Unless you're actually using GCC, in which case that hasn't been supported in several years so there's no expectation that it works. Your problem might just go away by switching to a modern NDK. 

--
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/b974d542-7999-4e3d-90a1-c23665c4d169n%40googlegroups.com.

Ariel Malka

unread,
Oct 3, 2023, 5:44:25 PM10/3/23
to andro...@googlegroups.com
Thank you Dan, that was indeed the problem (I was using a very old version of the NDK to build with gcc)

You received this message because you are subscribed to a topic in the Google Groups "android-ndk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-ndk/S_EbW1xs00Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-ndk...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAFVaGhvd9KfVakxTg3y7o_g3eDVSKryqAKdiCXSzrt6BtgOq_w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages