I have a large Android project with lots of native and Java code. The Java code debugs fine. All breakpoints are being hit.
The native debugger connects, but breakpoints are never hit. I am using ndk-build.
In my gradle file I have declared the following:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
debuggable false
jniDebuggable false
}
debug {
debuggable true
jniDebuggable true
minifyEnabled false
packagingOptions{
doNotStrip "*/armeabi-v7a/*.so"
doNotStrip "*/arm64-v8a/*.so"
doNotStrip "*/x86/*.so"
doNotStrip "*/x86_64/*.so"
}
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
Where I have declared my native function in Java, they show up red with the error "Cannot Resolve Corresponding JNI Function"
I have followed every step of this post: " Cannot Resolve Corresponding JNI Function" Android Studio
The project builds and runs fine, yet the native functions are not recognized in Java.
One thing I noticed is that there is no armeabi-v7a folder in obj\local\
But there are armeabi-v7a folders in
build\intermediates\transforms\stripDebugSymbol\release\0\lib
build\intermediates\transforms\mergeJniLibs\release\0\lib
build\intermediates\ndkBuild\release\obj\local
build\intermediates\ndkBuild\debug\obj\local
.externalNativeBuild\ndkBuild\release
.externalNativeBuild\ndkBuild\debug
Are there any other obscure settings that might disable native debugging?
EDIT:
This is how I declare my native functions in Java (BaseActivity.java):
native boolean SetupProject ();
This is how I declare them in C++:
JNIEXPORT jboolean JNICALL Java_com_mycompany_myapp_BaseActivity_SetupProject(JNIEnv * env, jobject obj) {
//some code
return JNI_TRUE;
}
EDIT2:
Library load:
static {
try {
System.loadLibrary("myapp");
} catch( UnsatisfiedLinkError e ) {
Log.e("MyApp", "Native code library failed to load: " + e);
}
}
Android.mk:
LOCAL_PATH := $(call my-dir)
MY_LOCAL_PATH := $(LOCAL_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := myapp
FILE_LIST_APP := $(wildcard $(LOCAL_PATH)/App/*.cpp)
LOCAL_SRC_FILES += $(FILE_LIST_APP:$(LOCAL_PATH)/%=%)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/App
LOCAL_SHORT_COMMANDS := true
APP_SHORT_COMMANDS := true
LOCAL_CFLAGS := -O0 -Wno-error -fshort-wchar -fpermissive -g -ggdb -ffast-math
LOCAL_LDLIBS := -lm -llog -ljnigraphics -ldl
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -ldl
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -lz
LOCAL_LDLIBS += -landroid
include $(BUILD_SHARED_LIBRARY)
Application.mk:
APP_PLATFORM := android-25
APP_CFLAGS += -Wno-error=format-security
APP_OPTIM := debug
APP_STL := gnustl_static