Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intermittent Android NDK UnsatisfiedLinkError

I have been getting sporadic, difficult to reproduce UnsatisfiedLinkErrors, most commonly when my application has been paused for a long time (i.e., hours). These errors occur on JNI calls that normally work.

Does Android sometimes unload a library without completely closing an application? I load my native library in one activity but also use it in another activity. Could Android be destroying the activity that loaded the library and unloading it, then failing to reload the library when the other activity that uses it is resumed?

like image 326
pbsurf Avatar asked Aug 06 '26 23:08

pbsurf


1 Answers

Everytime you load a library with an Activity like this,

   static {
        System.loadLibrary("gamescript");
    }       

Then the library is loaded within the Activity class like a local static member and will not be unloaded until the app is alive. However, my doubt is if it will be accessible from outside the class.

like image 168
codetiger Avatar answered Aug 09 '26 13:08

codetiger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!