spectrum
spectrum copied to clipboard
Runtime error: couldn't find DSO to load: libspectrumpluginjpeg.so
I updated my application on the play store with app bundle
. And then I saw lots of crash on crashlytics.
Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libspectrumpluginjpeg.so
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:703)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:564)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:500)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:455)
at com.facebook.spectrum.plugins.SpectrumPluginJpeg.ensureLoadedAndInitialized(SpectrumPluginJpeg.java:31)
at com.facebook.spectrum.plugins.SpectrumPluginJpeg.get(SpectrumPluginJpeg.java:48)
at com.facebook.spectrum.DefaultPlugins.get(DefaultPlugins.java:21)
at my.app.packname.MyApplication.onCreate(MyApplication.java:40)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1046)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5475)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1563)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6196)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
Dependency:
implementation 'com.facebook.spectrum:spectrum-default:1.0.0'
The crash came from different device models and Android versions. What is wrong with lib?
Hi @fgustovo,
The error message indicates that the delivered APK(s) do not include the mentioned so files or that the SoLoader cannot find it. Let's work through the following steps:
- Is there anything particular in your
build.gradle
file regarding native libraries such as setting ABI filters? - When taking the final APK (or the base+configuration APKs), do they contain the mentioned
libspectrumpluginjpeg.so
file?
There are similar issues regarding app bundles and the SoLoader that we are using. If the aforementioned steps show the right output (i.e. the .so files are indeed present for the right architectures), then let's dig deeper on that front.
Hi I am using this filter
bundle {
language {
enableSplit = true
}
density {
enableSplit = true
}
abi {
enableSplit = true
}
release {
minifyEnabled true
shrinkResources true
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
signingConfig signingConfigs.release
ndk {
abiFilters 'x86', 'armeabi-v7a', 'arm64-v8a'
}
}
and
minSdkVersion 21
targetSdkVersion 28
Please help asap. I am stuck
Hi @mukkumukesh
I start to suspecting that the SoLoader library that Spectrum is using does not properly load .so files in combination with app bundles. I am working on allowing to use the System SoLoader instead with the hope that it can help in these situations.
Until then, can you check that the .so file is actually included in the bundle files as you would expect it? You can follow the instructions described in https://developer.android.com/studio/command-line/bundletool to generate the final APK. Then use unzip -l
or another tool to verify the bundled .so files. A dump of all .so files that are within that APK would be helpful for us :) also let us know the device you are testing on.
I checked all apks generated by bundletool
and all include libspectrumpluginjpeg.so
files in the lib
directory.
I tried two different release bundles, one doesn't include any abifilters and other one contains abiFilters 'armeabi-v7a', 'x86'
. Both make crash.
When i tried with emulator huawei p20 lite API 28 x86
there isn't any problem. But crash occurred in real device huawei mate 10
.
I hope the information helps you @lambdapioneer
@fgustovo, the Huwaei mate 10 has a 64-bit CPU. Can you try again after adding arm64-v8a
to the ABI filters?
@lambdapioneer I tried two different release bundles, one doesn't include any abifilters and other one contains abiFilters 'armeabi-v7a', 'x86'. Both make crash.
I've landed a change that will allow to use the system's soloader instead of the Facebook one: https://github.com/facebookincubator/spectrum/commit/233ed539af32f064f3264bd3de139c6b4c7eb7b3
This will available as soon as we ship the next release v1.1. We anticipate that this happens next week. If you are curious to build locally in the mean time and test this change, then that would be super helpful.
In both cases, the initialization in the application class should be updated to the following:
Kotlin:
SpectrumSoLoader.init(yourAppContext, SpectrumSoLoader.SystemSoLoaderImpl())
Java:
SpectrumSoLoader.init(yourAppContext, new SoLoaderWrapper.SystemSoLoaderImpl());
The release artefacts are now pushed. @fgustovo if you like you can upgrade to v1.1.0 and check whether the SystemSoLoaderImpl
fixes the issue :)
It is not fixed
@khemrajiitk, do you have a local repo? We haven't succeeded to reproduce this locally and we are running out of ideas.
Can you provide the following information? Same applies for the others if the issue persists. If the issue is fixed by using the SystemSoLoader
then that's also valuable information for us.
- The full
build.gradle
file (minus any sensitive content) - One concrete device type and version of the crash (then we can try to get one for reproduction)
- One .apk file that crashes
- Does our sample app work (debug and release)?
- Setting the
dlopen
logging as described here: https://www.youtube.com/watch?v=L9GF_X-cq3E&t=1349s - The full
adb logcat
after setting thedlopen
logging
@lambdapioneer It will not work when I use
bundle {
abi {
enableSplit false
}
}
but it will increase my apk size.
my build.gradle file ``
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
splits {
abi {
enable true
}
}
bundle {
abi {
enableSplit true
}
}
Using SystemSoLoaderImpl
actually fixed the issue for me, thanks for that! It is important to note, however, that the given Kotlin code crashes due to Kotlin adding a typecast to the generated Java code:
Kotlin:
SpectrumSoLoader.init(yourAppContext, SpectrumSoLoader.SystemSoLoaderImpl())
Generated Java code:
SpectrumSoLoader.init((Context)yourAppContext, (SoLoaderWrapper)(new SystemSoLoaderImpl()));
In the generated Java code the SystemSoLoaderImpl
is cast to SoLoaderWrapper
, which is a package private interface, causing the following exception:
java.lang.IllegalAccessError: Illegal class access: '<yourClassHere>' attempting to access 'com.facebook.spectrum.SpectrumSoLoader$SoLoaderWrapper' ...
If anyone knows a way to disable the Kotlin typecasting 'feature', please let me know :). For now I'll just use an old fashioned Java class to initialize the SpectrumSoLoader. Perhaps the interface could be made public?
@iMvBremen, thanks a lot for the reply and I'm glad that the SystemSoLoaderImpl
solved the problem for you.
Regarding the Kotlin type-cast: that's interesting. If you like, you can send a PR for making the interface public :) otherwise, I'll try to get to it.