Monday, 23 September 2019

"JNI FatalError called: Unable to load library"

I have a unity project configured to be a dynamic feature module. This installs perfectly fine on-demand. But when I run it, the app crashes with following error:

JNI FatalError called: Unable to load library: /data/app/com.example.app-8fx1RRZrQ34BcwXf8ajjqZ==/lib/arm64/libunity.so [dlopen failed: library "libunity.so" not found]

The target activity of the Unity project includes SplitCompat.install(this);

And it's gradle looks like:

    // GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN

    buildscript {
        repositories {
            mavenCentral()
            google()
            jcenter()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.0'
        }
    }

    allprojects {
        repositories {
            mavenCentral()
            google()
            jcenter()
            flatDir {
                dirs 'libs'
            }
        }
    }

    apply plugin: 'com.android.dynamic-feature'

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
    }

    android {
        compileSdkVersion rootProject.compileSdk
        buildToolsVersion rootProject.buildTools

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }

        defaultConfig {
            minSdkVersion rootProject.minSdk
            targetSdkVersion rootProject.targetSdk
            versionCode rootProject.versionCode
            versionName rootProject.versionName

            ndk {
                abiFilters 'armeabi-v7a', 'arm64-v8a'
            }
        }

        lintOptions {
            abortOnError false
        }

        aaptOptions {
            noCompress = ['.unity3d', '.ress', '.resource', '.obb']
        }

        flavorDimensions "default"

        productFlavors {
            staging {
                dimension "default"
            }

            production {
                dimension "default"
            }

            develop {
                dimension "default"
            }
        }

        compileOptions {
            sourceCompatibility 1.8
            targetCompatibility 1.8
        }

        buildTypes {
            debug {
                minifyEnabled false
                useProguard false
                jniDebuggable true
            }
            release {
                minifyEnabled false
                useProguard false
            }
        }

        packagingOptions {
            doNotStrip '*/armeabi-v7a/*.so'
            doNotStrip '*/arm64-v8a/*.so'
    //        doNotStrip '*/x86/*.so'
        }

    }

    dependencies {
        implementation project(':app')
    }

While the gradle of app module has:

    bundle {
        language {
            // Specifies that the app bundle should not support
            // configuration APKs for language resources. These
            // resources are instead packaged with each base and
            // dynamic feature APK.
            enableSplit = false
        }
        density {
            // This property is set to true by default.
            enableSplit = false
        }
        abi {
            // This property is set to true by default.
            enableSplit = true
        }
    }

I even tried disabling the .so compression by setting android.bundle.enableUncompressedNativeLibs = false in gradle.properties file, but the exact error persists.

How may I resolve this?



from "JNI FatalError called: Unable to load library"

No comments:

Post a Comment