Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Runtime error: couldn't find DSO to load: libspectrumpluginjpeg.so #43

Open
fgustovo opened this issue Apr 22, 2019 · 13 comments
Open

Runtime error: couldn't find DSO to load: libspectrumpluginjpeg.so #43

fgustovo opened this issue Apr 22, 2019 · 13 comments
Assignees
Labels
bug Something isn't working fixed - waiting for release Marks issues that have been fixed and will ship with the next release. needs-details

Comments

@fgustovo
Copy link

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?

@lambdapioneer
Copy link
Contributor

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.

@lambdapioneer lambdapioneer added bug Something isn't working needs-details labels Apr 23, 2019
@lambdapioneer lambdapioneer self-assigned this Apr 23, 2019
@mukkumukesh
Copy link

mukkumukesh commented May 9, 2019

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

@lambdapioneer
Copy link
Contributor

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.

@fgustovo
Copy link
Author

fgustovo commented May 14, 2019

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

@lambdapioneer
Copy link
Contributor

@fgustovo, the Huwaei mate 10 has a 64-bit CPU. Can you try again after adding arm64-v8a to the ABI filters?

@fgustovo
Copy link
Author

@lambdapioneer I tried two different release bundles, one doesn't include any abifilters and other one contains abiFilters 'armeabi-v7a', 'x86'. Both make crash.

@lambdapioneer
Copy link
Contributor

I've landed a change that will allow to use the system's soloader instead of the Facebook one: 233ed53

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());

@lambdapioneer lambdapioneer added the fixed - waiting for release Marks issues that have been fixed and will ship with the next release. label May 17, 2019
@lambdapioneer
Copy link
Contributor

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 :)

@khemrajiitk
Copy link

It is not fixed

@lambdapioneer
Copy link
Contributor

@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 the dlopen logging

@khemrajiitk
Copy link

khemrajiitk commented Jun 16, 2019

@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
        }
    }

@iMvBremen
Copy link

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?

@lambdapioneer
Copy link
Contributor

@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.

facebook-github-bot pushed a commit that referenced this issue Jul 15, 2019
Summary:
As from discussion in #43

This PR fixes issue when Kotlin generated code adds typecast to `SoLoaderWrapper` and this causes `IllegalAccessError` at run time as classes can't access package private `SoLoaderWrapper` interface.

**Kotlin:**
```
SpectrumSoLoader.init(context, SpectrumSoLoader.SystemSoLoaderImpl())
```

**Generated:**
```
SpectrumSoLoader.init((Context)context, (SoLoaderWrapper)(new SystemSoLoaderImpl()));
```

**Run-time error:**
```
java.lang.IllegalAccessError: Illegal class access: 'com.example.SpectrumLoader' attempting to access 'com.facebook.spectrum.SpectrumSoLoader$SoLoaderWrapper' (declaration of 'com.example.SpectrumLoader' appears in /data/app/com.example.dev-ZTjIGlrpJnf4A8NSyFKk4g==/split_lib_slice_2_apk.apk)
```
Pull Request resolved: #177

Reviewed By: diegosanchezr

Differential Revision: D16262267

Pulled By: cuva

fbshipit-source-id: 0b34f5c4446b36e7d63e5043f98bbe4ad6d8e972
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working fixed - waiting for release Marks issues that have been fixed and will ship with the next release. needs-details
Projects
None yet
Development

No branches or pull requests

5 participants