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.
Internals of the feature module as seen in the aab. The .so libs are present:
How may I resolve this?
Update 1 -
The problem i've described above occurs when the aab is installed from play store for the first time. Note that I am able to successfully install the feature module and the error occurs only when I attempt to run it. However, when I push an incremental update over the same installation, the feature module is somehow able to work flawlessly and is able to find the necessary .so file. I've tried these steps several times on repeat to validate the observation.