简体   繁体   中英

Why does the Android GC collect my native library References when the application is in Background?

I'm developing an Android application which uses a native library (.so). I use System.load to load it and I add a JNI jar file to the classPath to make many references to an object created in my library. The problem is, when my application is in background, Android removes all references to library object (all references are a static variable pointed to object in C++ lib), so the application crashes when resuming.

Can anyone help me please?

NB: I have an exception UnsatisfiedLinkError .

The garbage collector does not. Rather you are experiencing cases where the application is being resumed in an entirely new process which has not yet loaded the native library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM