Catch UnsatisfiedLinkError Exception

140 views
Skip to first unread message

Pascal Merle

unread,
Jul 3, 2009, 12:43:31 PM7/3/09
to android-ndk
I would like to optionally add native code. If there is no library for
the platform that my application is run it should work without the
additional code.

That what I tried:
try {
System.loadLibrary("mylib");
loaded = true;
} catch (Exception e) {
}

However the application still crashes if the library is not present.
How can I detect if the library is loadable for the target platform?

Doug Schaefer

unread,
Jul 3, 2009, 1:10:48 PM7/3/09
to andro...@googlegroups.com
UnsatisfiedLinkError isn't actually an Exception. You probably want to catch Throwable, which covers Errors and Exceptions.

fadden

unread,
Jul 6, 2009, 2:32:01 PM7/6/09
to android-ndk
On Jul 3, 10:10 am, Doug Schaefer <cdtd...@gmail.com> wrote:
> UnsatisfiedLinkError isn't actually an Exception. You probably want to catch
> Throwable, which covers Errors and Exceptions.

Better yet, catch UnsatisfiedLinkError, which will handle the specific
situation without also ignoring other potential problems.
Reply all
Reply to author
Forward
0 new messages