MSDK v5 with Dynamic Feature Modules
Hello,
We are encountering an issue when we setup the MSDK v5.16 inside of a dynamic feature module. The setup we currently have is a dynamic feature module with an Activity. Inside of this activity we have
override fun attachBaseContext(newBase: Context?) {
super.attachBaseContext(newBase)
SplitCompat.installActivity(this)
SplitCompat.install(applicationContext)
Helper.install(this.applicationContext as Application)
}
After installing the module and launching the activity we are getting a crash when Helper.install runs. The crash is
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1007 in tid 4147 (.app), pid 4147 (.app)
/data/data/<app_id>/files/splitcompat/6/native-libraries/msdkv5_connect.config.arm64_v8a/libSdkyclx_clx.so
/data/data/<app_id>/files/splitcompat/6/native-libraries/msdkv5_connect.config.arm64_v8a/libSdkyclx_clx.so
[anon:dalvik-classes.dex extracted in memory from /data/user/0/<app_id>/files/splitcompat/6/verified-splits/msdkv5_connect.apk] (com.cySdkyc.clx.Helper.install+64)
[anon:dalvik-classes4.dex extracted in memory from /data/user/0/<app_id>/files/splitcompat/6/verified-splits/msdkv5_connect.apk!classes4.dex] (com.app.msdkv5_connect.MSDKRegistrationActivity.attachBaseContext+68)
When the feature module is installed with the base app there is no crash with the same code. I also tested on v5.8 and did not see the crash there which had the old Helper.install method.
The method of testing we are using is building a .aab file inside of android studio. Then using the bundle tool command to generate an apk
bundletool build-apks --bundle=app-debug.aab \
--output=app.apks \
--local-testing
Then installing app.apks to the device with
bundletool install-apks --apks=app.apks
Device: Pixel 5a on Android 11 MSDK Version: 5.16 (happens on 5.12 as well)
I appreciate any guidance on how the MSDK should be added to a dynamic feature module.
Agent comment from YIGUI LIU in Zendesk ticket #157251:
Dear Developer,
After confirming with the MSDK R&D team, currently, as described in the tutorial documentation (https://developer.dji.com/doc/mobile-sdk-tutorial/en/quick-start/user-project-caution.html), it is required to call com.cySdkyc.clx.Helper.install(this) in the attachBaseContext of Application.
This requirement is due to MSDK's security policy. The older version com.secneo.sdk.Helper.install has different requirements for invocation.
Best Regards,
DJI Innovations SDK Technical Support Team
°°°
Thank you, I have noticed the same crash when I call Helper.install from the Application attachBaseContext in this context. I saw the crash with the following steps:
- Install base app without dynamic feature module (DJI MSDK)
- Install dynamic feature module but don't call
Helper.install - On next app launch, call
Helper.installin the ApplicationattachBaseContextvia reflection.
It all works when we manually install the dynamic feature module as an APK (with code above), only when using bundles and google's play feature delivery does it not work.
Agent comment from YIGUI LIU in Zendesk ticket #157251:
Dear Developer,
1、In the Run/Debug Configurations page of Android Studio, check the Always install with package manager option 2、Perform a Clean Project and then re-run the application.
Best Regards,
DJI Innovations SDK Technical Support Team
°°°
That works when installing the application from Android Studio but installing from Android App Bundle (AAB) is where the crash occurs. And it only occurs when the module is dynamically installed. If we mark the module to be installed at the start with
<dist:module
dist:instant="false"
dist:title="@string/title"
dist:onDemand="false">
<dist:fusing dist:include="true" />
</dist:module>
there is no crash and everything works fine. Its only when we do
<dist:module
dist:instant="false"
dist:title="@string/title">
<dist:delivery>
<dist:on-demand />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>
that we see the crash. Is there anything special we can do to get Dynamic Feature Modules working with the MSDK?
Thanks
Agent comment from YIGUI LIU in Zendesk ticket #157251:
Dear Developer,
This should be by design of the MSDK. As described in the tutorial documentation (https://developer.dji.com/doc/mobile-sdk-tutorial/en/quick-start/user-project-caution.html), the MSDK requires calling com.cySdkyc.clx.Helper.install(this) in the attachBaseContext of the Application, and this call is supposed to require dynamic installation.
Best Regards,
DJI Innovations SDK Technical Support Team
°°°