5

We have a strange problem with our Android app. In Fabric we have a very infrequent crash. It is a standard UnsatisfiedLinkError meaning that in the static initializer of the Java class, the .so library fails to load. This is what we have found out so far:

  • The problem is very rare. It happens in a couple of hundred devices out of hundreds of thousands or of installations.

  • Once it happens, it seems like restarting or even reinstallationdoes not solve it.

  • It happens across various brands like Sony, Samsung, Huawei.

  • It happens across all Android versions from 2.3 to 5.x.

  • We managed to catch it once in the office on a Nexus 1 device. When it started to happen, it always failed in the LoadLibrary call even though the same apk worked just fine on other devices.

  • When the problem happened, I removed the armv7a and x86 versions of the lib and only left the armeabi one to rule out the wrong lib was loaded, it still failed. Re-running the app through Android studio several times adding logs still caused the failure in the same place.

  • Then all of a sudden, without no obvious change, it started to work in the Nexus 1 and even after dozens of retries, we can not reproduce the problem again. The only thing that happened before it started to work was that I tried to manually install a corrupt apk with adb install which failed and the next time I loaded the app through Android studio, it worked and has worked even since. I am not sure if the failed installation of the corrupt apk somehow cleaned something out or if it was just a coincidence.

  • The thing I failed to do was to check that the armeabi .so file was actually present in the lib folder on the device when the failure occurred. I only came to think about this after it had already started to work.

So, to sum up. The apk is perfectly fine but and installs fine from Android studio the Play store on 99,9% of the devices but then under certain conditions (which are very rare), the LoadLibrary fails and when it does, there seems to be no obvious fix, not even reinstalling solved it but as I explained, something finally changed and when it started working on the Nexus 1, it has continued to work ever since.

This problem is really tricky since we have no way of reproduce it right now and we know it is affecting at least a small group of our users.

Any suggestions on how to narrow this down are welcome.

user1816142
  • 1,199
  • 2
  • 9
  • 16
  • We faced the same problem, then we catch all the UnsatisfiedLinkError and disable the relevant functions. Maybe it has something to do with the environment of Android OS, but it's really hard to explain. – Hong Duan Sep 26 '15 at 11:46
  • 1
    In our case the app can not function without the dynamic lib so turning things off will not work. However it is interesting to hear that you have also encountered this problem. – user1816142 Sep 26 '15 at 12:08
  • 1
    http://stackoverflow.com/questions/32425865/race-condition-in-android-dlopen suggests that there is a race condition that does not show if _loadLibrary()_ is called from the right class in a static initializer. Suggestion: move the static initializer that loads the library to a different class (and first of all check that it _is_ a static initializer). – 18446744073709551615 Sep 28 '15 at 09:41
  • we too facing same issue,out of some thousand devices and only in few devices its happening,even though we are loading our .so files in application class too,still now we dont have any clear idea – immutable Jun 18 '17 at 13:25

0 Answers0