Eno*_*Eno 6 java-native-interface linker android android-ndk
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";
}
}
Run Code Online (Sandbox Code Playgroud)
尽管有这个问题,但当我尝试运行此代码并且缺少库时,我仍然得到一个UnsatisfiedLinkError.为什么我没有抓住异常?我究竟做错了什么?
ogn*_*ian 10
UnsatisfiedLinkError不是的子类Exception.层次结构UnsatisfiedLinkError是:
Throwable->Error->UnsatisfiedLinkError
Run Code Online (Sandbox Code Playgroud)
UnsatisfiedLinkError如果你想处理它,你最好抓住它.
| 归档时间: |
|
| 查看次数: |
1875 次 |
| 最近记录: |