Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.UnsatisfiedLinkError #201

Closed
wassupnari opened this issue Aug 28, 2015 · 5 comments
Closed

java.lang.UnsatisfiedLinkError #201

wassupnari opened this issue Aug 28, 2015 · 5 comments

Comments

@wassupnari
Copy link

Hi @koral--

Thanks for providing an awesome library!

I started using GifImageView for a few weeks, but I'm getting a crash report which is caused from:

Caused by: java.lang.UnsatisfiedLinkError: Couldn't load pl_droidsonroids_gif from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.myapp.team-1.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]]: findLibrary returned null at java.lang.Runtime.loadLibrary(Runtime.java:358) at java.lang.System.loadLibrary(System.java:533) at pl.droidsonroids.gif.GifInfoHandle.(GifInfoHandle.java:40) at pl.droidsonroids.gif.GifDrawable.(GifDrawable.java:145) at pl.droidsonroids.gif.GifDrawable.(GifDrawable.java:83) at pl.droidsonroids.gif.GifViewUtils.setResource(GifViewUtils.java:49) at pl.droidsonroids.gif.GifViewUtils.getResourceId(GifViewUtils.java:35) at pl.droidsonroids.gif.GifViewUtils.initImageView(GifViewUtils.java:22) at pl.droidsonroids.gif.GifImageView.(GifImageView.java:41) at java.lang.reflect.Constructor.constructNative(Constructor.java) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:594) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377) at android.app.Activity.setContentView(Activity.java:1997) at com.myapp.team.activity.intro.SplashAnimScreen.onCreate(SplashAnimScreen.java:71) at android.app.Activity.performCreate(Activity.java:5312) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2541) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641) at android.app.ActivityThread.access$800(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5867) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674) at dalvik.system.NativeStart.main(NativeStart.java)

Any thoughts?

Thanks,
Nari

@koral--
Copy link
Owner

koral-- commented Aug 29, 2015

UnsatisfiedLinkError means that native library (.so file) cannot be loaded because it is either not included in APK or cannot be read (see #51). If you are using this library as a gradle dependency and have no custom abiFilters, .so files should be included properly.

@wassupnari
Copy link
Author

Hi @koral--

Thanks for the quick reply! :)

In my case, it works fine for most of devices, except HTC One (Android version 4.4.3). It seems like one of your .so has the same name as HTC One's, so that the system chose to use its existing shared library, not yours. What do you think?

I'd like to investigate this further, but I'm not good at JNI. Can I get the names of .so from this project?

@koral--
Copy link
Owner

koral-- commented Aug 30, 2015

Even if HTC uses the same library file name and it will be loaded instead of proper one, then no UnsatisfiedLinkError should be thrown at loading time because loading will be successful. Optionally some linkage error may be thrown later when one of the library method is called.

From this fragment of stacktrace:

Caused by: java.lang.UnsatisfiedLinkError: Couldn't load pl_droidsonroids_gif from loader

we see that library name is pl_droidsonroids_gif so .so file is called libpl_droidsonroids_gif.so

I looked deeper into that stacktrace and found an interesting detail:

dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.myapp.team-1.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]]: findLibrary returned null at

Here we see that file was tried to be found in /vendor/lib and /system/lib. There is no application-private directory there.
I've simulated attempt to load non-existent library on API level 19 emulator and got a little bit different nativeLibraryDirectories

Caused by: java.lang.UnsatisfiedLinkError: Couldn't load invalid_name from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/pl.droidsonroids.gif.sample-2.apk"],nativeLibraryDirectories=[/data/app-lib/pl.droidsonroids.gif.sample-2, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)

So it seems that library loading failed on mentioned HTC because for some reason nativeLibraryDirectories is incomplete there. I don't know (yet) why it happened.

Possible workaround may be loading library by specifying full path explicitly using System.load().

@koral--
Copy link
Owner

koral-- commented Oct 15, 2015

Closing due to inactivity. One of the hints: https://github.com/koral--/android-gif-drawable/issues/217#issuecomment-148273091

@koral-- koral-- closed this as completed Oct 15, 2015
@koral--
Copy link
Owner

koral-- commented Nov 9, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants