java.lang.UnsatisfiedLinkError

Hi guys.

We are seeing this crash sometimes in some devices at the Google Play Console logs. Can’t repro locally any of the devs / qa.

java.lang.UnsatisfiedLinkError: 
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1067)
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1007)
  at java.lang.System.loadLibrary (System.java:1667)
  at com.rmsl.juce.Java.<clinit> (Unknown Source:2)
  at com.rmsl.juce.Java.initialiseJUCE (Native Method)
  at com.mycompany.MyApp.onCreate (Unknown Source:139)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1190)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6905)
  at android.app.ActivityThread.access$1300 (ActivityThread.java:269)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2010)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:7860)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1075)

I am using a custom Java Application class to handle some Usb permissions, but at the end of onCreate it calls Java.initialiseJUCE (this);

Any tips?

An UnsatisfiedLinkError indicates that a library (.so file) cannot be found. Given that you’re only seeing this crash sometimes, and cannot reproduce it on your developer devices, my guess is that these devices have a ABI which you’re not currently building for.

For example, this could happen if you’re only building for arm64 but the app is getting installed on an x86_64 device. I’d start by looking at the Play Console logs to see if the crashing devices have ABIs which you don’t currently support.

Should fail all the time at those devices then?

From build.graddle generated by Projucer I can see

productFlavors {
        debug_ {
            ndk {
                abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
            }
            externalNativeBuild {
                cmake {
                    arguments "-DJUCE_BUILD_CONFIGURATION=DEBUG", "-DCMAKE_CXX_FLAGS_DEBUG=-O0", "-DCMAKE_C_FLAGS_DEBUG=-O0"
                }
            }

            dimension "default"
       }
        release_ {
            externalNativeBuild {
                cmake {
                    arguments "-DJUCE_BUILD_CONFIGURATION=RELEASE", "-DCMAKE_CXX_FLAGS_RELEASE=-O3", "-DCMAKE_C_FLAGS_RELEASE=-O3"
                }
            }

            dimension "default"
       }
    }

Interesing the abi filters only appear on _debug product flavours?

The devices where the error have been seen have
arm64-v8a
armeabi-v7a
armeabi

Check your release APK - what .so files are included in it?

It contains those 4 variants. armeabi-v7a, x86, arm64-v8a, x86_64.

I make and upload Bundles with release builds to Google Play.

Thanks btw don!

Hmmm, that’s strange then. Can you post a list of the affected devices?

  • Samsung Galaxy A20s
  • Samsung Galaxy J6

Both at Android 10 (SDK 29)

Hello @danisonuus,

Could you please let me know if you’ve found a solution to your java.lang.UnsatisfiedLinkError bug? I also have a few Android users of my app experiencing the same issue at the start of my application. Thanks a lot for your help.

ToBy

Hey ToBy.

It’s been a while but I did a few things:

  • added @Keep to my custom Application class.
  • added this as well to the same application class (just to be extra paranoid!)
static
    {
        System.loadLibrary ("juce_jni");
    }
  • also disabled minify on my build.graddle. On Extra module’s build.gradle content on Projucer:
android {
    buildTypes {
        release {
            minifyEnabled false
        }
    }