We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2003

Summary: Android rare bug : FindLibrary return null
Product: SDL Reporter: Sylvain <sylvain.becker>
Component: *don't know*Assignee: Gabriel Jacobo <gabomdq>
Status: RESOLVED WONTFIX QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: ARM   
OS: Android (All)   
Attachments: new findlibrary with extraction of .so from .apk

Description Sylvain 2013-08-01 02:31:59 UTC
Hi,

this is a very rare and strange bug I got from google-play reports.
it appears only for 1 per 100 000 user I guess.

Basically FindLibrary() return null, so SDL and other Lib cannot be loaded and App won't start.

I have no idea ...

here's two stack straces :

java.lang.ExceptionInInitializerError
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1409)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1761)
at android.app.ActivityThread.access$1500(ActivityThread.java:124)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:947)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3822)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load SDL2: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:429)
at java.lang.System.loadLibrary(System.java:554)
at org.libsdl.app.SDLActivity.<clinit>(SDLActivity.java:55)

More verbose stack trace has :

Caused by: java.lang.UnsatisfiedLinkError: Couldn't load SDL2 from loader dalvik.system.PathClassLoader[dexPath=/data/app/net.MyCompany.MyApp-2.apk,libraryPath=/data/app-lib/net.MyCompany.MyApp-2]: findLibrary returned null

It appears with the following phones :
CM980
Huawei-U8652
U8510
ALCATEL ONE TOUCH 918
ZTE V768
GT-S5830i
U8655-1
XT550


Thanks,

Sylvain
Comment 1 Sam Lantinga 2013-08-01 02:38:14 UTC
Maybe corrupt or incomplete installation?
Comment 2 Gabriel Jacobo 2013-08-01 08:04:54 UTC
I've seen this happen when the runtime dependencies of the SDL2.so are not met, which probably means the Android version the user has is below the minimum (which may happen if they side load the app for example, or you have the wrong setting in AndroidManifest.xml). Hard to say for sure without more information.
Comment 3 Sylvain 2013-08-01 16:45:33 UTC
Here's the little changes I did : 

I modified the "AndroidManifest.xml" with the following :
  <!-- Android 2.3.3 at Least, but tested and targeted on API-17 -->
  <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" />

I modified "project.properties"
  target=android-17

I've just noticed that "default.properties" contains : 
  target=android-7

If it was a dependency missing I would expect the name of a function or a library. Well I don't know..
Comment 4 Gabriel Jacobo 2013-11-06 14:27:00 UTC
Do you have additional info to help track this down?
Comment 5 Sylvain 2013-11-06 15:07:23 UTC
To be optimistic, I would say it seem to appear less often. But still maybe 1 per 20000 install.



Sometimes the exception appears with a *weird* path see the suffix "-2" : 
-----------------------------------------------------------------------
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load SDL2 from loader dalvik.system.PathClassLoader[dexPath=/data/app/net.myapp.mygame-2.apk,libraryPath=/data/data/net.myapp.mygame/lib]: findLibrary returned null


Once I also got this one : 
-------------------------
Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: get_lib_extents[760]: 73 - /mnt/asec/net.myapp.mygame-1/lib/libSDL2_mixer.so is not a valid ELF object
at java.lang.Runtime.loadLibrary(Runtime.java:434)
at java.lang.System.loadLibrary(System.java:554)
at org.libsdl.app.SDLActivity.<clinit>(SDLActivity.java:57)

(Notice that libSD2_mixer is loaded after libSDL2! so why this occured only for mixer and not for SDL2 ??)


Also, I got (recently : 1 sept. 2013) : 
-------------------------------------
java.lang.UnsatisfiedLinkError: Native method not found: org.libsdl.app.SDLActivity.onNativeSurfaceChanged:()V
at org.libsdl.app.SDLActivity.onNativeSurfaceChanged(Native Method)
at org.libsdl.app.SDLSurface.surfaceChanged(SDLActivity.java:518)
at android.view.SurfaceView.updateWindow(SurfaceView.java:591)
at android.view.SurfaceView.access$000(SurfaceView.java:83)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:177)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:726)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2086)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1127)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4650)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:747)
at android.view.Choreographer.doCallbacks(Choreographer.java:567)
at android.view.Choreographer.doFrame(Choreographer.java:536)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:733)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)

(and also today only : java.lang.UnsatisfiedLinkError: onNativeSurfaceChanged)


Notice that it always only appears maybe 1 per 20.000 install ! With severals apps.
All my apps have no obvious bug :). Valgrind cleaned (on linux, I did not tried on device). It compiles with no warning, with many compilers (gcc,clang, and winrt/windows8). I dont use opengl directly, but only the sdl renderer.
I think I have the option -fno-rtti and I dont use the dynamic cast.

I used to compile with ndk-9, but will switch to ndk-9b.
I plan to release a new game in a couple of days.

Tell me if you need more information.
Comment 6 Gabriel Jacobo 2013-11-06 16:18:52 UTC
The onNativeSurfaceChanged error could happen if you mismatched the SDLActivity.java file with the wrong libSDL2.so file. It ought to be consistent though (several reports from everyone that tries your app).

As it is, I'm inclined to mark this as "won't fix", there's stuff involved in this that we can't do anything about (funky Android distros, low memory/disk space situations?) even if we can figure out what the actual problem is.
Comment 7 Sylvain 2013-11-06 16:38:22 UTC
No problem to mark this as "won't fix", I totally understand the lack of information and reproduction steps.
Comment 8 Gabriel Jacobo 2013-11-11 22:27:11 UTC
Marking as WONTFIX for reasons stated above. Thanks for the feedback !
Comment 9 Sylvain 2013-11-20 08:16:23 UTC
I Just add more information about this issue ...

- Problem still happening with a new application. so using the latest version of SDL.

- For this release, I build all the different abi (arm,arm-v7a,x86,mips) in different .apk and it is still happening.

- I made only 1 version of the application. So the problem is not while "upgrading" the application.

- phones are :

hwy210-0151
Galaxy Ace (GT-S5830)
yecon75_tb_ics
hexing77_ics2
Wildfire S (marvel)
hwy210-0151
ZTE V793 (P175A60)
Comment 10 Sylvain 2013-12-05 23:00:53 UTC
Created attachment 1482 [details]
new findlibrary with extraction of .so from .apk
Comment 11 Sylvain 2013-12-05 23:01:53 UTC
Hello,

here a few links of people having the same problem.

https://code.google.com/p/android/issues/detail?id=59420

http://stackoverflow.com/questions/16450035/how-can-i-make-android-delete-old-native-libraries/16683835#16683835

https://code.google.com/p/android/issues/detail?id=35962


And for information, here is also a patch where I try to extract the libs from the .apk (if the usual *load library* path fails).
It seems to work as I stop getting those "UnsatisfiedLinkError" since I use it !


Thanks,

Sylvain