android-image-filter icon indicating copy to clipboard operation
android-image-filter copied to clipboard

UnsatisfiedLinkError on some devices

Open harunurhan opened this issue 10 years ago • 3 comments

I added this library to my projects, it works properly on some devices but it does not on some others. System.loadLibrary line, throws an exception because library cannot be loaded. I unzip the apk and check libAndroidImageFilter.so is created for all architecture.

There is no common among problematic devices. Some of them are KitKat whereas some other are JellyBean. Most of them are Samsung but there are also several HTC. Also there are a Samsung devices which does not have any crash. Furthermore, even though all of them has armv7 based cpu, there are a few armv7 based devices on which the library is able to run.

In short, I have no idea why it crashes on some devices.

harunurhan avatar Sep 15 '14 13:09 harunurhan

Could you show the crash stack? This may be caused by the *.so library was broken or the system doesn't put it on the correct directory, so I think you can put the *.so into your apk's assets directory, when you catch UnsatisfiedLinkError, you can load the library from assets.

ragnraok avatar Sep 16 '14 05:09 ragnraok

*.so is not broken because the same apk works on some devices whereas it does not on some other. May be the System.loadLibrary has different default library path on these devices which crash.

I tried to load library in a different way when I catch UnsatisfiedLinkError, like System.load("/data/data/my.package/lib/libmysharedlibrary.so") this also throws UnsatisfiedLinkError. This solution also works on devices which don't crash previously, but still does not work on problematic devices.

About your suggestion, If I put my *.so into my ape's assets directory what would be the correct path to load it. Is it /data/data/my.package/assets/libmysharedlibrary.so ?

harunurhan avatar Sep 16 '14 07:09 harunurhan

Well, you can copy the *.so into the directory like /data/data/your.package.name/recover_lib when the app is initializing, and if you catch UnsatisfiedLinkError after call System.loadLibrary as usual, you can load the library from that directory

ragnraok avatar Sep 16 '14 15:09 ragnraok