question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't load libraries that are in dynamic feature modules

See original GitHub issue

I’m trying to include a React Native activity in a dynamic feature module. It works when it’s included in the base APK, but it looks like some hackery is needed when loading native libraries that are in an installed dynamic feature module: SplitInstallHelper.loadLibrary() should be used on 26+ rather than System.loadLibrary(). Currently I’m getting a crash saying the native library couldn’t be found, and this seems like the most likely culprit. Since SoLoader is the one making the actual call, I’m not sure how I could do that from my end. I tried using sSystemLoadLibraryWrapper, but it looks like my loadLibrary() never gets called.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:19

github_iconTop GitHub Comments

2reactions
erkschcommented, Feb 19, 2021

You can use my fork of SoLoader on the develop branch, build it and include the AAR in your project and see if it works.

Should be something like

dependencies {
      ...
     implementation ('com.facebook.react:react-native:+') {
          exclude group: 'com.facebook.soloader', module: 'soloader'
     }
     implementation name: 'soloader', ext: 'aar'
}

repositories {
      flatDir {
           dirs 'libs'
      }
}
1reaction
erkschcommented, Feb 14, 2021

Weird, it doesn’t work for me. The SoLoader does not find the native libraries:

D/SoLoader: About to load: libjscexecutor.so
D/SoLoader: libjscexecutor.so not found on /data/data/<package>/lib-main
D/SoLoader: libjscexecutor.so not found on /data/data/<package>/lib-0
D/SoLoader: libjscexecutor.so not found on /data/data/<package>/lib-1
D/SoLoader: libjscexecutor.so not found on /data/app/<package>-LxW4qT73Kp0GBM4oUp20OQ==/lib/arm64
D/SoLoader: libjscexecutor.so not found on /vendor/lib
D/SoLoader: libjscexecutor.so not found on /system/lib
E/SoLoader: couldn't find DSO to load: libjscexecutor.so result: 0

The native libraries are actually located in

/data/data/<package>/files/splitcompat/3/native-libraries/dynamicfeature.config.arm64_v86/

But the SoLoader does not seem to pick up this path. I wonder why it would work for you if your libs are in the same location.

I guess this is where SplitInstallHelper.loadLibrary() would search for.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Third party library of dynamic feature module cannot access ...
Currently you can access Dynamic Module via reflection and having dynamic features defined through public interfaces in a common library ...
Read more >
Using native library inside dynamic feature module: Part 1
We will create a new project which contains an app module and add a dynamic feature module. Both of these modules contain activities...
Read more >
Unable to install dynamic feature module after clearing app data
Go to app and install modules common and feature1 in a single session request. OK . · Install module feature2 . · Clear...
Read more >
Navigate with feature modules - Android Developers
When you navigate to one of these destinations, the Dynamic Navigator library first checks if the feature module is installed. If the feature ......
Read more >
Reusing Dynamic Feature Modules (DFM)
Note: running the app directly from Android Studio will not show “downloading module” screen. You have to use internal app sharing to test...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found