I have created a cc_library in my bazel Build file and added the deps in android_binary rule
Bazel BUILD:
cc_library(
name = "native_libs",
srcs = glob([
"app/src/main/jni/**/*.cc",
"app/src/main/jni/**/*.h",
]),
)
android_binary(
name = "buildlib",
srcs = glob([
"app/src/main/java/**/*.java",
]),
manifest = "app/src/main/AndroidManifest.xml",
deps = ":native_libs",
)
And loaded the library in the specified package as
static{
System.loadLibrary("buildlib");}
And declares and calls the native function as :
Declaration:
private static native String foo(String code);
Function Call
foo("Code");
JNI FILE FUNCTION DECLARATION AND DEFINITION:
JNIEXPORT jstring JNICALL
Java_com_example_android_(foo)( JNIEnv* env, jobject thiz, jstring code );
JNIEXPORT jstring JNICALL
Java_com_example_android_(foo)( JNIEnv* env, jobject thiz, jstring code )
{
//some code
return code;
}
The library gets loaded successfully but while function call throws an error of java.lang.UnsatisfiedLinkError
How can i called the native foo() from my java file?