I have an Android project that contains a class that uses JNI to pull a value from a C function. The C function was built into a library using NDK. The value returned from the C function is in turn used to initialize a variable inside a class when its first loaded. This works fine. However, I also want it to work when the library is missing by providing a default value. So Im using something like this:
static native String getstring();
static {
try {
System.loadLibrary("library");
NAME = getstring();
}
catch (Exception e) {
NAME = "Default";
}
}
Despite the catch, Im still getting a UnsatisfiedLinkError when I try to run this code with the library missing. Why am I not catching the exception? What am I doing wrong?