How to unload a native library?

10,030 views
Skip to first unread message

wavelet

unread,
May 15, 2010, 3:57:01 AM5/15/10
to android-platform
Hi all,
I use the below snippet to load a native shared library
static {
System.loadLibrary("mylib_name");
}


How I can unload the lib manually.

thanks.

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

Octaviano Flores

unread,
May 24, 2010, 1:16:14 PM5/24/10
to android-...@googlegroups.com, ying...@gmail.com
wavelet,

You just delete it from system/lib

Regards,
-Octaviano

Ted Neward

unread,
May 24, 2010, 5:10:45 PM5/24/10
to android-...@googlegroups.com, ying...@gmail.com

There’s a bit of a difference between unloading and uninstalling, Octaviano. :-)

 

There is no Java-approved way to unload a native library (there is no System.unloadLibrary() call.) This is part of the reason Java has so often downplayed JNI in general. You might be able to write a JNI call to do a dlunload() (or whatever its equivalent on Dalvik/Android is), but that would itself require another native library.

 

Ted Neward

Java, .NET, XML Services

Consulting, Teaching, Speaking, Writing

http://www.tedneward.com

David Turner

unread,
May 24, 2010, 7:12:23 PM5/24/10
to android-...@googlegroups.com, ying...@gmail.com
Yes, there is no way to unload the library from Java. You can still call "dlclose()" from native code if you need this though.
(Of course, you may not be able to call dlclose() from the shared library you are unloading without crashing).
Reply all
Reply to author
Forward
0 new messages