Cannot load library if library failed to load previously
chuckhacker opened this issue · 15 comments
After switching to ReLinker, I recently recently received this report from one my users. It seems like if a previous call to System.load()
fails for a given library, then the library does not load in subsequent calls?
java.lang.UnsatisfiedLinkError: Cannot load library: find_library(linker.cpp:901): "/data/data/com.LearnImmersive.Lingoland/app_lib/libLingolandNativeActivity.so" failed to load previously
at java.lang.Runtime.load(Runtime.java:341)
at java.lang.System.load(System.java:500)
at com.getkeepsafe.relinker.SystemLibraryLoader.loadPath(SystemLibraryLoader.java:29)
at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:198)
at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:139)
at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:95)
at com.LearnImmersive.Lingoland.LingolandApplication.onCreate(LingolandApplication.java:71)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1003)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4661)
at android.app.ActivityThread.access$1300(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5400)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:837)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604)
at dalvik.system.NativeStart.main(Native Method)
I am not sure how to diagnose this one further than this. I noticed some log statements inside your library that I will be sure to remotely propagate over rsyslog in a future release.
If it helps, I also received the following information:
Android version: Android 4.2
Device: ONE TOUCH 4015X (Yaris35_GSM) 1
Manufacturer: TCT Mobile Limited (Alcatel)
Android version: Android 4.2
RAM: (MB) 512
Screen size: 320 × 480
Screen density (dpi): 160
OpenGL ES: version 2.0
Native platform: armeabi-v7a
CPU make: Mediatek
CPU model: MT6572M
Chances are I can obtain additional information from this user, but his technical knowledge is definitely average.
Hmm, interesting! Thanks for the report. I'll dive into the linker code and see what "failed to load" previously is about and what we can do about it.
The weird thing is that this library is the highest library up the dependency chain, and it is the very last library that I load (i.e. shouldn't it "fail" sooner? Right now, it seems deferred until the subsequent failure.):
public class LingolandApplication extends Application {
public void onCreate(){
super.onCreate();
RLOG.w("LingolandApplication", "onCreate");
AppRTCUtils.logDeviceInfo("LingolandApplication");
RLOG.i("LingolandApplication", "ACRA");
ACRA.init(this);
RLOG.i("LingolandApplication", "zo");
ReLinker.recursively().loadLibrary(this, "zo");
RLOG.i("LingolandApplication", "jpego");
ReLinker.recursively().loadLibrary(this, "jpego");
RLOG.i("LingolandApplication", "assimp");
ReLinker.recursively().loadLibrary(this, "assimp");
RLOG.i("LingolandApplication", "jingle_peerconnection_so");
ReLinker.recursively().loadLibrary(this, "jingle_peerconnection_so");
RLOG.i("LingolandApplication", "LingolandNativeActivity");
ReLinker.recursively().loadLibrary(this, "LingolandNativeActivity");
RLOG.i("LingolandApplication", "Survived loading LingolandNativeActivity");
}
Do you mind giving the output of $ readelf -d lib.so | grep NEEDED
for your libraries? It would let me know what libraries ReLinker knows about. Also, if you're using 1.2RC, you can log more detailed output with log(Logger)
, that information is useful too if possible to get.
It seems like this is an unfortunate reality for Android versions < JB MR2 (18) as evidenced here https://code.google.com/p/android/issues/detail?id=22143
Fixed here https://android-review.googlesource.com/#/c/48534/
I figured out a simple repro, have a library with an intra-library dependency defined and dont have the dependency on the device. The linker wont find the dependency for your library the first time, and if you catch that and try again it will spit out the "failed to load previously" exception.
It seems like this should be a transient issue where a simple app kill / re-load will fix it. If its happening each time the app is loaded, then you may actually be missing a library dependency, so please check on that. If you have all libraries packaged, it may mean that there might be corrupt data on the device.
Looking at the linker code, there is a way to unload / reset the error flag for libraries, but you can't seem to call it from Java. So if I were to try and solve this issue auto-magically, it would mean that I would be bundling a native library of my own with ReLinker specifically targeting API < 18.
That doesn't sound too bad, however I'd like to avoid it if possible. So lets see if its a transient issue or a configuration issue first.
@xiphirx Okay, I am pushing a live update that remote logs ReLinker logs. Our user who encountered the bug is super responsive on WhatsApp and is happy to help us test, so I'll let you know when I fish out the logs.
chuck@Chucks-Mac-Pro ~/LingolandNative/app/test/app-arm7-release (master●●●)$ greadelf -d lib/armeabi-v7a/libzo.so | grep NEEDED [ruby-2.0.0p645]
0x00000001 (NEEDED) Shared library: [libstdc++.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
chuck@Chucks-Mac-Pro ~/LingolandNative/app/test/app-arm7-release (master●●●)$ greadelf -d lib/armeabi-v7a/libassimp.so | grep NEEDED
0x00000001 (NEEDED) Shared library: [libzo.so]
0x00000001 (NEEDED) Shared library: [libstdc++.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
chuck@Chucks-Mac-Pro ~/LingolandNative/app/test/app-arm7-release (master●●●)$ greadelf -d lib/armeabi-v7a/libjpego.so | grep NEEDED [ruby-2.0.0p645]
0x00000001 (NEEDED) Shared library: [libstdc++.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
chuck@Chucks-Mac-Pro ~/LingolandNative/app/test/app-arm7-release (master●●●)$ greadelf -d lib/armeabi-v7a/libjingle_peerconnection_so.so | grep NEEDED [ruby-2.0.0p645]
0x00000001 (NEEDED) Shared library: [liblog.so]
0x00000001 (NEEDED) Shared library: [libGLESv2.so]
0x00000001 (NEEDED) Shared library: [libOpenSLES.so]
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
0x00000001 (NEEDED) Shared library: [libm.so]
chuck@Chucks-Mac-Pro ~/LingolandNative/app/test/app-arm7-release (master●●●)$ greadelf -d lib/armeabi-v7a/libLingolandNativeActivity.so | grep NEEDED [ruby-2.0.0p645]
0x00000001 (NEEDED) Shared library: [libandroid.so]
0x00000001 (NEEDED) Shared library: [libEGL.so]
0x00000001 (NEEDED) Shared library: [libGLESv2.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
0x00000001 (NEEDED) Shared library: [liblog.so]
0x00000001 (NEEDED) Shared library: [libzo.so]
0x00000001 (NEEDED) Shared library: [libassimp.so]
0x00000001 (NEEDED) Shared library: [libjpego.so]
0x00000001 (NEEDED) Shared library: [libjingle_peerconnection_so.so]
0x00000001 (NEEDED) Shared library: [libstdc++.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libc.so]
It seems like this should be a transient issue where a simple app kill / re-load will fix it. If its happening each time the app is loaded, then you may actually be missing a library dependency, so please check on that. If you have all libraries packaged, it may mean that there might be corrupt data on the device.
That doesn't seem to be the case. The user has tried restarting many times, but the app never succeeds loading.
If its happening each time the app is loaded, then you may actually be missing a library dependency, so please check on that.
I just double-checked, and my APK has all of the correct libraries in it.
If you have all libraries packaged, it may mean that there might be corrupt data on the device.
I wouldn't put it past him, he's using a very obscure device. Perhaps I should report checksums.
Looking at the linker code, there is a way to unload / reset the error flag for libraries, but you can't seem to call it from Java. So if I were to try and solve this issue auto-magically, it would mean that I would be bundling a native library of my own with ReLinker specifically targeting API < 18.
I can do this on my end, it is not much trouble for me. What call do I make?
If at all possible, I want to be able to support API level >= 16. I'm actually going to even try for >= 9. Most of our app's users come from geographic locales that have larger-than-expected shares of older devices. They would be delighted if our app can run on their devices.
It would be cool if you can try unloading the library in your own native code, if that works then we can put it inside of ReLinker. It only becomes a chicken and egg sort of problem though when devices fail to load ReLinker's bundled .so file :)
If you want to unload a library, it seems like you want to link libdl
and call dlclose(1)
, as described here http://osxr.org:8080/android/source/bionic/linker/dlfcn.c#0159 . Here's some sample code using it http://osxr.org:8080/android/source/development/ndk/platforms/android-4/samples/san-angeles/jni/importgl.c#0165
So, to see if this would help, you would try / catch your last library load function, if an exception is thrown, you would unload the problem library and try again. Doing this would get past the "failed to load previously" message.
By wanting to support api >= 16, you will run into this issue since this misconfiguration in Bionic was fixed in API 18. I definitely would love to have ReLinker fix it for you, but I'm still unsure as to what is going wrong in the linking process. It seems like the reason a library can "fail to load" is pretty broad, ranging from not having an intra-library dependency present to corrupt offsets within the ELF format, etc.
Thanks for putting forth the effort to try it out! I really appreciate it :)
EDIT: working on the native code right now, I'll let you know when it's ready
Good news, I was able to repro the problem on a grouper tablet (ASUS Nexus 7 2012 wifi) running 4.2, it looks like I found something:
03-17 23:35:43.978 3817-3817/com.LearnImmersive.Lingoland W/LingolandApplication: LingolandApplication: onCreate
03-17 23:35:43.978 3817-3817/com.LearnImmersive.Lingoland D/LingolandApplication: LingolandApplication: Android SDK: 16, Release: 4.1.2, Brand: Google, Device: grouper, Id: JZO54K, Hardware: grouper, Manufacturer: Asus, Model: Nexus 7, Product: nakasi
03-17 23:35:43.978 3817-3817/com.LearnImmersive.Lingoland I/LingolandApplication: LingolandApplication: ACRA
03-17 23:35:44.008 3817-3817/com.LearnImmersive.Lingoland I/ACRA: ACRA is enabled for com.LearnImmersive.Lingoland, initializing...
03-17 23:35:44.068 3817-3817/com.LearnImmersive.Lingoland I/LingolandApplication: LingolandApplication: Start loading libraries
03-17 23:35:44.068 3817-3817/com.LearnImmersive.Lingoland I/LingolandApplication: LingolandApplication: zo
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_ABIS
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland W/dalvikvm: VFY: unable to resolve static field 155 (SUPPORTED_ABIS) in Landroid/os/Build;
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: VFY: replacing opcode 0x62 at 0x0006
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_ABIS
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/dalvikvm: DexOpt: unable to optimize static field ref 0x009b at 0x0b in Lcom/getkeepsafe/relinker/SystemLibraryLoader;.supportedAbis
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of zo...
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/lib/libzo.so 0x414ae840
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Added shared lib /data/data/com.LearnImmersive.Lingoland/lib/libzo.so 0x414ae840
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /data/data/com.LearnImmersive.Lingoland/lib/libzo.so 0x414ae840, skipping init
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: zo (null) was loaded normally!
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/LingolandApplication: LingolandApplication: jpego
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of jpego...
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/lib/libjpego.so 0x414ae840
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Added shared lib /data/data/com.LearnImmersive.Lingoland/lib/libjpego.so 0x414ae840
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /data/data/com.LearnImmersive.Lingoland/lib/libjpego.so 0x414ae840, skipping init
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: jpego (null) was loaded normally!
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/LingolandApplication: LingolandApplication: assimp
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of assimp...
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/lib/libassimp.so 0x414ae840
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Added shared lib /data/data/com.LearnImmersive.Lingoland/lib/libassimp.so 0x414ae840
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /data/data/com.LearnImmersive.Lingoland/lib/libassimp.so 0x414ae840, skipping init
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: assimp (null) was loaded normally!
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/LingolandApplication: LingolandApplication: jingle_peerconnection_so
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of jingle_peerconnection_so...
03-17 23:35:44.078 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/lib/libjingle_peerconnection_so.so 0x414ae840
03-17 23:35:44.088 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Added shared lib /data/data/com.LearnImmersive.Lingoland/lib/libjingle_peerconnection_so.so 0x414ae840
03-17 23:35:44.098 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: jingle_peerconnection_so (null) was loaded normally!
03-17 23:35:44.098 3817-3817/com.LearnImmersive.Lingoland I/LingolandApplication: LingolandApplication: LingolandNativeActivity
03-17 23:35:44.098 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of LingolandNativeActivity...
03-17 23:35:44.098 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/lib/libLingolandNativeActivity.so 0x414ae840
03-17 23:35:44.098 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: LingolandNativeActivity (null) was not loaded normally, re-linking...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of android...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /system/lib/libandroid.so 0x414ae840, skipping init
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: android (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of EGL...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /system/lib/libEGL.so 0x414ae840, skipping init
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: EGL (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of GLESv2...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /system/lib/libGLESv2.so 0x414ae840, skipping init
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: GLESv2 (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of dl...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /system/lib/libdl.so 0x414ae840, skipping init
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: dl (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of log...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /system/lib/liblog.so 0x414ae840, skipping init
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: log (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of zo...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/lib/libzo.so 0x414ae840
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Shared lib '/data/data/com.LearnImmersive.Lingoland/lib/libzo.so' already loaded in same CL 0x414ae840
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: zo (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of assimp...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/lib/libassimp.so 0x414ae840
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Shared lib '/data/data/com.LearnImmersive.Lingoland/lib/libassimp.so' already loaded in same CL 0x414ae840
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: assimp (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of jpego...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/lib/libjpego.so 0x414ae840
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Shared lib '/data/data/com.LearnImmersive.Lingoland/lib/libjpego.so' already loaded in same CL 0x414ae840
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: jpego (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of jingle_peerconnection_so...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/lib/libjingle_peerconnection_so.so 0x414ae840
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Shared lib '/data/data/com.LearnImmersive.Lingoland/lib/libjingle_peerconnection_so.so' already loaded in same CL 0x414ae840
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: jingle_peerconnection_so (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of stdc++...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /system/lib/libstdc++.so 0x414ae840, skipping init
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: stdc++ (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of m...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /system/lib/libm.so 0x414ae840, skipping init
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: m (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: Beginning load of c...
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: No JNI_OnLoad found in /system/lib/libc.so 0x414ae840, skipping init
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland I/Relinker: Relinker: c (null) was loaded normally!
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: Trying to load lib /data/data/com.LearnImmersive.Lingoland/app_lib/libLingolandNativeActivity.so 0x414ae840
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland D/AndroidRuntime: Shutting down VM
03-17 23:35:44.108 3817-3817/com.LearnImmersive.Lingoland W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x410a9300)
03-17 23:35:44.118 3817-3817/com.LearnImmersive.Lingoland E/ACRA: ACRA caught a UnsatisfiedLinkError for com.LearnImmersive.Lingoland
java.lang.UnsatisfiedLinkError: Cannot load library: find_library[1226]: 138 'libLingolandNativeActivity.so' failed to load previously
at java.lang.Runtime.load(Runtime.java:340)
at java.lang.System.load(System.java:521)
at com.getkeepsafe.relinker.SystemLibraryLoader.loadPath(SystemLibraryLoader.java:29)
at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:198)
at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:139)
at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:95)
at com.LearnImmersive.Lingoland.LingolandApplication.onCreate(LingolandApplication.java:80)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4336)
at android.app.ActivityThread.access$1300(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1268)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4931)
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:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
03-17 23:35:44.168 3817-3817/com.LearnImmersive.Lingoland I/dalvikvm: Could not find method android.os.StatFs.getBlockSizeLong, referenced from method org.acra.util.ReportUtils.getAvailableInternalMemorySize
03-17 23:35:44.168 3817-3817/com.LearnImmersive.Lingoland W/dalvikvm: VFY: unable to resolve virtual method 1594: Landroid/os/StatFs;.getBlockSizeLong ()J
03-17 23:35:44.168 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: VFY: replacing opcode 0x6e at 0x0013
03-17 23:35:44.168 3817-3817/com.LearnImmersive.Lingoland I/dalvikvm: Could not find method android.os.StatFs.getBlockSizeLong, referenced from method org.acra.util.ReportUtils.getTotalInternalMemorySize
03-17 23:35:44.168 3817-3817/com.LearnImmersive.Lingoland W/dalvikvm: VFY: unable to resolve virtual method 1594: Landroid/os/StatFs;.getBlockSizeLong ()J
03-17 23:35:44.168 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: VFY: replacing opcode 0x6e at 0x0013
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland E/dalvikvm: Could not find class 'android.hardware.display.DisplayManager', referenced from method org.acra.collector.DisplayManagerCollector.collectDisplays
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland W/dalvikvm: VFY: unable to resolve check-cast 185 (Landroid/hardware/display/DisplayManager;) in Lorg/acra/collector/DisplayManagerCollector;
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: VFY: replacing opcode 0x1f at 0x0034
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland I/dalvikvm: Could not find method android.view.Display.getFlags, referenced from method org.acra.collector.DisplayManagerCollector.collectFlags
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland W/dalvikvm: VFY: unable to resolve virtual method 18281: Landroid/view/Display;.getFlags ()I
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland I/dalvikvm: Could not find method android.view.Display.isValid, referenced from method org.acra.collector.DisplayManagerCollector.collectIsValid
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland W/dalvikvm: VFY: unable to resolve virtual method 18292: Landroid/view/Display;.isValid ()Z
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: VFY: replacing opcode 0x6e at 0x0019
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland I/dalvikvm: Could not find method android.view.Display.getName, referenced from method org.acra.collector.DisplayManagerCollector.collectName
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland W/dalvikvm: VFY: unable to resolve virtual method 18284: Landroid/view/Display;.getName ()Ljava/lang/String;
03-17 23:35:44.218 3817-3817/com.LearnImmersive.Lingoland D/dalvikvm: VFY: replacing opcode 0x6e at 0x0019
03-17 23:35:46.278 3817-3891/? I/Process: Sending signal. PID: 3817 SIG: 9
Hmm... It seems like ReLinker should probably spit out the exception it catches to the logger...
Is this a local repro? If so, can you just simply call System.load(/data/data/com.LearnImmersive.Lingoland/app_lib/libLingolandNativeActivity.so);
(not loadLibrary) and log the exception?
Dumb oversight on my part... the logging mechanism in ReLinker should log the actual error encountered. Opened #16
Also, is libLingolandNativeActivity.so
built differently than the other libraries? Are you building all of these libraries yourself? What NDK revision are you using?
Also, pro-tip: You can capture a ReLinkerInstance
with ReLinker.recursively()
and reuse it. Each instance will keep track of what libraries it loaded already, preventing redundant loads of common dependencies (libdl, libc, libm, etc)
ReLinker will now log the actual stacktrace. This should tell us why libLingolandNativeActivity.so is a problem.
java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1331]: 138 cannot locate '__isnanf'...
Okay, now we're talkin! Actually, I think there was an NDK update or two, and I hadn't rebuilt all of the dependent libraries. Let me see if that fixes it.
I'm still going to investigate the workaround for the API level < 18 issue as well.
Either way, the extra logging change is much appreciated!
Also, please try to target your NDK build against API 19 and / or utilize NDK r9d to compile your code.
Thanks @xiphirx -- I realize now that you are going a bit above and beyond your call of duty as a ReLinker dev, so I sent you a gift at work.
The rebuild on NDK r9d worked great on the "ancient tablet," but that's a two year old toolchain (doesn't even support 64-bit ABIs). Can I target against API 19 with NDK 11?
Ideally, I'm using the new NDK going forward because I did have to hack Google Breakpad a bit to get things to compile (things like the system user_regs_struct
aren't defined for ARM in the header files for NDK 9).
Why would __isnanf
be missing anyhow? Is it actually because of new hardware floating point support in later NDK versions that simply isn't backwards compatible?
Funny thing is, I haven't encountered the aforementioned Bionic issue on my tablet at all (fingers crossed!).
Thank you for the gift! I'm glad to hear that building with NDK r9d worked out!
To know why r9d worked vs anything above it, you can refer to this issue.
What compiler are you using btw? Try GCC with a higher optimization level, it seems like it might inline the function in your code removing the dependency on an external library. More info can be found here
You can try statically linking your dependencies... which might result in a gigantic binary, but it should work fine everywhere. You might also be able to get away with defining __isnanf
in your own code, but that will probably wont be maintainable for the future.
Additionally, you could compile API specific binaries, where API < 20 devices are served binaries compiled with r9d and devices > API 20 are served binaries compiled with the latest toolchain. This would be terrible to manage, I'd imagine, but should work theoretically... And if you choose to do this, you wont get the benefit of ReLinker since we strictly look for /abi/lib.so
in your APK
If you're feeling adventurous, Google actually has a alternative "crazy" linker you can include with your App that might solve your issues.
However, all in all it seems like this is a problem with the system / configuration rather than loading / linking libraries. The left over tidbit that is interesting for ReLinker is the viability of including "crazy linker" in the library and unconditionally utilizing it instead of relying on the system's linker. Of course, if you choose to try out "crazy linker", any feedback you could provide on that would be very helpful.
I'm going to go ahead and close this issue. Please open another issue if you choose to investigate crazy linker and have information to share, or if you encounter any other issues while using ReLinker!
This report was quite useful! :)
Just to be sure, is the "approved" solution supposed to be targeting API 19 or using NDK r9d?
I'm saying because in my project, we targeted API 26 with min API 16 and NDK r19b and we got the error when loading with ReLinker (the final fix was this).
Should I create a new issue? Thanks!