1

I have a problem getting the native debugging support to work for my Eclipse project under Windows for Android. Google unfortunately didn't help after more than 1 day of research.

I am pretty much a beginner with eclipse, so the solution might be easy because I do also some non-standard things I guess.

My android project is already functioning and running fine on my devices (Acer Iconia A500 Android 3.2.1, HTC Incredible S Android 4.0.4 etc.).

I created the project with the ADT Plugin Wizard and then added native support by using the project context menu entry added by ADT.

I then added the java files I already had (previously I used to compile with CMake and the Android stand-alone toolchain, though I never tried to remote debug this way). I created a new package for that "com.x.y" where I dropped them on to (I don't want to reveal the real package name as the project will be part of a commercial product).

Then I added my Sources by dragging them into the jni folder. The sources are not located inside the jni folder but are linked to a location "../../" below the project (Its part of a cross platform application so I can reuse the source files accross different toolchains).

I also link against 4 static libraries that will be shipped with the product by adjusting the Android.mk the following way:

LOCAL_PATH := $(call my-dir)
MY_PATH := $(LOCAL_PATH)
LOCAL_PATH := $(MY_SDK)/lib/Android/armeabi-v7aD

include $(CLEAR_VARS)
LOCAL_MODULE    := A
LOCAL_SRC_FILES := libA.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := B
LOCAL_SRC_FILES := libB.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := C
LOCAL_SRC_FILES := libC.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE    := D
LOCAL_SRC_FILES := libD.a
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_C_INCLUDES += $(my_SDK)/include/
LOCAL_PATH := $(MY_PATH)/../../..
LOCAL_CFLAGS  += -Wno-format -DANDROID -fno-rtti -fno-exceptions #And many other flags If they are important I will post them later, too
LOCAL_CPPFLAGS += -fno-rtti -fno-exceptions
LOCAL_MODULE    := MY_PROJECT
LOCAL_SRC_FILES := Android/Main.cpp # Some other sources..
LOCAL_LDLIBS    := -lstdc++ -lEGL -lGLESv2 -llog -Wl,--allow-multiple-definition -Wl,--no-undefined 
LOCAL_STATIC_LIBRARIES := A B C D

include $(BUILD_SHARED_LIBRARY)

I also have a Application.mk:

APP_ABI := armeabi-v7a
APP_PLATFORM := android-9
APP_STL := stlport_static
APP_CFLAGS += -fno-rtti -fno-exceptions

Then I added under Debug Configurations a new "Android Native Application" launching the default Activity and using

Debugger "${NdkGdb}"

Command File "${NdkProject}\libs\${NdkCompatAbi}\gdb.setup"

Shared Libraries (Added automatically) ${NdkProject}/obj/local/$NdkCompatAbi}/

The rest is also added automatically and I think should work this way.

One thing that I think is odd is that I get the console Output

[2013-03-08 10:50:36 - Unable to launch cygpath. Is Cygwin on the path?] java.io.IOException: Cannot run program "cygpath": CreateProcess error=2, The system cannot find the file specified

But I can build the project fine this way and later I don't get any warnings trying to attach gdb (I am using Msys, I also have cygwin installed so I don't know why Eclipse is complaining here).

When I launch the application, it starts up on the device and then I get the following Console output([Android Native Application] gdb):

(no debugging symbols found)
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
Error while mapping shared library sections:
libstdc++.so: No such file or directory.

... And alot more of that type

(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
No line 219 in file "jni/../../../MySourceFile.cpp".

I definitely build with NDK_DEBUG=1, my static .a Libraries are build with -g AndroidManifest.xml has an entry android:debuggable="true".

When I run "sh /ndk-gdb --verbose" in the eclipse project directory (using Msys) I get the following output:

Android NDK installation path: /c/SDK/android-ndk-r7 Using default adb command: /c/SDK/android-sdks/platform-tools/adb.exe ADB version found: Android Debug Bridge version 1.0.31 Using final ADB command: '/c/SDK/android-sdks/platform-tools/adb.exe' Using auto-detected project path: . Found package name: com.x.y ABIs targetted by application: armeabi-v7a Device API Level: 13 Device CPU ABIs: armeabi-v7a armeabi Compatible device ABI: armeabi-v7a Found debuggable flag: true ERROR: Non-debuggable application installed on the target device. Please re-install the debuggable version!

I really want to have native debugging support for this project. So I really appreciate any help.

Is it true that I have to use cygwin? I don't get any reasonable error message for that while trying to attach the debugger.

ecreif
  • 1,182
  • 1
  • 12
  • 25
  • You clearly know a lot more about the details of this than I do, but my observation is that eclipse is pretty uncomfortable when you import files unless you are careful. I would create the project and the class files inside eclipse, and cut and paste the code into these files. Once that's tidied up and the resources are there, copy the libraries into the libs directory of the project, and I think Eclipse will do the rest. Or have I missed the point? – Neil Townsend Mar 08 '13 at 15:00
  • Copying code would be the last thing i want to do, Its a lot cleaner(I think) if all my toolchains access the same source files without copying the content manually. But you are right, I should test at least if setting up the project by avoiding the linked resources feature fixes the gdb problem. Thanks – ecreif Mar 08 '13 at 15:22

0 Answers0