No source file named during debug... but why?

6 views
Skip to first unread message

Julian LALU

unread,
Jun 6, 2014, 6:22:11 AM6/6/14
to andro...@googlegroups.com
Hello,

I'm trying to debug a simple application using ndk r9d and ADT Eclipse.I will try t explain everything quickly for helping :)

I have 2 projects in my workspace, a library and an android application.

Here is the files hierarchy of the library:
    (dir)  src
      |
      | (dir)  com.lib.mylib
      |   |
      |   |  JNI.java
      |   |
      | (dir)  jni
      |   |
      |   | MyLib.cpp
      |   | Adnroid.mk
      |   |
      |   | (dir)  module
      |   |   |
      |   |   | MyNative.cpp
      |   |   | Android.mk
      |   |   |

In my library i have this simple java class in the src folder:

JNI.java
   
public class JNI
{
    public static native String getStringNative();
    public static native int getValue();
}

I also have 2 sources files in the jni folder:

MyLib.cpp

#include <jni.h>
   
extern "C"
{
    JNIEXPORT jstring JNICALL Java_com_lib_mylib_JNI_getStringNative(JNIEnv* env, jobject obj)
    {
        return env->NewStringUTF("voila");
    }
}
 
MyNative.cpp

#include <jni.h>
   
extern "C"
{
   JNIEXPORT jint JNICALL Java_com_lib_mylib_JNI_getValue(JNIEnv* env, jobject obj)
    {
        return 202;
    }
}

To build with the NDK i'm using 2 Android.mk files:

The first in the jni directory:

ROOT_LOCAL_PATH := $(call my-dir)
LOCAL_PATH := $(ROOT_LOCAL_PATH)
   
include $(LOCAL_PATH)/module/Android.mk
   
include $(CLEAR_VARS)
   
LOCAL_PATH := $(ROOT_LOCAL_PATH)
   
LOCAL_MODULE    := MyLib
LOCAL_SRC_FILES := MyLib.cpp
LOCAL_STATIC_LIBRARIES := MyNative
   
include $(BUILD_SHARED_LIBRARY)

This one call the following Android.mk in the module directory:

LOCAL_PATH := $(call my-dir)
   
include $(CLEAR_VARS)
   
LOCAL_MODULE    := MyNative
LOCAL_SRC_FILES := MyNative.cpp
   
include $(BUILD_STATIC_LIBRARY)

I build the library with ndk-build NDK_DEBUG=1.

When i want to use this library, i use it this way:

public class MainActivity extends ActionBarActivity {
   
    static{
        System.loadLibrary("MyLib");
    }
       
    private String mName;
    private int mValue;

    @Override    
    protected void onCreate(Bundle savedInstanceState) {
        Debug.waitForDebugger();
        mName = JNI.getStringNative();
        mValue = JNI.getValue();
    }
}

When i try to debug as native application and set a breakpoint in MyNative.cpp i have the following error in the log:

No source file named MyNative.cpp.

This append only when i set a breakpoint.
In the debug configurations menu i set the shared libraries path to ...\obj\local\armeabi

I really don't know how i can debug this files. Does anybody can help me?

Thank you
Reply all
Reply to author
Forward
0 new messages