Search code examples
androidc++debuggingandroid-ndkndk-gdb

ndk-gdb unable to find gdb.setup


I am trying to use ndk-gdb to debug my native android project. When I run the command ndk-gdb I get the error

 Could not find gdb.setup under ./libs/

Explanation

  • Running MacOSX, ndk r10e; Using ndk sample San Angeles
  • Followed steps here to setup native debugging https://developer.android.com/ndk/guides/ndk-gdb.html
  • Basically I set android:debuggable="true", APP_OPTIM := debug and built native using ndk-build NDK_DEBUG=1 (these 3 setting may be superfluous, but just in case)
  • Used ant debug, adb install to install; Ran app and app runs fine
  • Running ndk-gdb --verbose produces

    ndk-gdb --verbose

    Android NDK installation path:

      /Users/hanantha/Documents/Dev/android-ndk-r10e
    

    Using default adb command:

     /Users/hanantha/Documents/Dev/android-sdk-macosx/platform-tools/adb
    

    ADB version found: Android Debug Bridge version 1.0.32

     Revision eac51f2bb6a8-android
    

    Using ADB flags:

    Using JDB command:

    /usr/bin/jdb
    

    Using auto-detected project path: .

    Found package name: com.example.SanAngeles

    ABIs targetted by application: arm64-v8a armeabi armeabi-v7a armeabi-v7a mips mips64 x86 x86_64

    Device API Level: 19

    Device CPU ABIs: x86

    Compatible device ABI:

    Using gdb setup init:

     ./libs/armeabi/gdb.setup
    

    Using toolchain prefix:

     /Users/hanantha/Documents/Dev/android-ndk-r10e/toolchains/x86-4.8/prebuilt/darwin-x86_64/bin/i686-linux-android-
    

    Using app out directory: ./obj/local/armeabi

    Found debuggable flag: true

    ERROR:

        Could not find gdb.setup under ./libs/
       This usually means you modified your AndroidManifest.xml to set
       the android:debuggable flag to 'true' but did not rebuild the
       native binaries. Please call 'ndk-build' to do so,
       *then* re-install to the device!
    

Solution

  • I just answered in the post: https://stackoverflow.com/a/32972182/1617066

    I ran into the same problem. It seems something changed in recent version of Android Build tools.

    The trick is:

    ERROR: Could not find gdb.setup under ./libs/
    

    It expects gdb.setup is in the directory libs but NOT libs/armeabi

    so the simple workground is to copy gdb.setup and gdbserver from "libs/cpu" to "libs" and it works like a magic!