Mobile SDK - FileProvider clashing with our own FileProvider

We are having FileProvider in our mobile app and when using Mobile SDK it is having FileProvider also, so we experience issues with them clashing together. When tapping onto attachment we get an app crash. Maybe anyone has ideas on how to solve this issue?

We can provide steps on how to reproduce it in sample app:

In the Genesys sample app (https://github.com/MyPureCloud/mobiledxsamples-android ), add in the AndroidManifest file the following under the application tag

<provider
 android:name="androidx.core.content.FileProvider"
 android:authorities="${applicationId}.fileprovider"
 android:exported="false"
 android:grantUriPermissions="true">
 <meta-data
 android:name="android.support.FILE_PROVIDER_PATHS"
 android:resource="@xml/file_provider_paths" />
</provider>

When building the app I get the following errors:

/Users/aboth/StudioProjects/mobiledx-samples-android/GCMessengerSDKSample/app/src/main/AndroidManifest.xml:35:13-64 Error:
Attribute provider#androidx.core.content.FileProvider@authorities value=(com.genesys.cloud.messenger.sample.fileprovider) from AndroidManifest.xml:35:13-64
is also present at [com.genesys.cloud:ui:1.10.0] AndroidManifest.xml:14:13-68 value=(com.genesys.cloud.messenger.sample.genesys.provider).
Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml:33:9-41:20 to override.
/Users/aboth/StudioProjects/mobiledx-samples-android/GCMessengerSDKSample/app/src/main/AndroidManifest.xml:40:17-60 Error:
Attribute meta-data#android.support.FILE_PROVIDER_PATHS@resource value=(@xml/file_provider_paths) from AndroidManifest.xml:40:17-60
is also present at [com.genesys.cloud:ui:1.10.0] AndroidManifest.xml:19:17-55 value=(@xml/provider_paths).
Suggestion: add 'tools:replace="android:resource"' to <meta-data> element at AndroidManifest.xml:38:13-40:63 to override.

So we add the recommended suggestion and we end up with the following in the manifest

<provider
 android:name="androidx.core.content.FileProvider"
 android:authorities="${applicationId}.fileprovider"
 android:exported="false"
 android:grantUriPermissions="true"
 tools:replace="android:authorities">
 <meta-data
 android:name="android.support.FILE_PROVIDER_PATHS"
 android:resource="@xml/file_provider_paths"
 tools:replace="android:resource"/>
</provider>

Now when we run the sample app and receive an attachment and click on it the app crashes with the
following error:

Process: com.genesys.cloud.messenger.sample, PID: 18591
 java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority com.genesys.cloud.messenger.sample.genesys.provider
 at androidx.core.content.FileProvider.getFileProviderPathsMetaData(FileProvider.java:664)
 at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:695)
 at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:645)
 at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:449)
 at com.genesys.cloud.ui.messenger.MessengerChatUIHandler.openFile(MessengerChatUIHandler.kt:371)
 at com.genesys.cloud.ui.messenger.MessengerChatUIHandler.handleEvent(MessengerChatUIHandler.kt:632)
 at
com.genesys.cloud.ui.structure.handlers.BaseChatUIHandler$chatViewModel$2.invoke$lambda$4$lambda$3$lambda$2$lambda$1(HandlersBase.kt:200)
 at com.genesys.cloud.ui.structure.handlers.BaseChatUIHandler$chatViewModel$2.$r8$lambda$Rwx9Wb0X3YzNtpZ6XsOhfEp0EpM(Unknown
Source:0)
 at com.genesys.cloud.ui.structure.handlers.BaseChatUIHandler$chatViewModel$2$$ExternalSyntheticLambda0.onChanged(Unknown Source:4)
 at com.genesys.cloud.ui.utils.SingleLiveData.observe$lambda$0(UItility.kt:101)
 at com.genesys.cloud.ui.utils.SingleLiveData.$r8$lambda$_3xhD4AyRVfBotP3yxC3_VJmdUA(Unknown Source:0)
 at com.genesys.cloud.ui.utils.SingleLiveData$$ExternalSyntheticLambda0.onChanged(Unknown Source:4)
 at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
 at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
 at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
 at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
 at com.genesys.cloud.ui.fragments.ChatViewModel.onHandleEvent(ChatViewModel.kt:123)
 at com.genesys.cloud.ui.fragments.ChatViewModel$elementControllerFactory$1$produceController$1$1.invoke(ChatViewModel.kt:145)
 at com.genesys.cloud.ui.fragments.ChatViewModel$elementControllerFactory$1$produceController$1$1.invoke(ChatViewModel.kt:145)
 at com.genesys.cloud.ui.structure.elements.ChatUIElementController.handleEvent(ChatUIElementController.kt:52)
 at com.genesys.cloud.ui.views.chatelement.BubbleContentHolder.updateAttachmentLayout$lambda$7$lambda$6(BubbleContent.kt:267)
 at com.genesys.cloud.ui.views.chatelement.BubbleContentHolder.$r8$lambda$PJQ-TsX6X0IPYikLGn3SLG1DNuU(Unknown Source:0)
 at com.genesys.cloud.ui.views.chatelement.BubbleContentHolder$$ExternalSyntheticLambda0.onClick(Unknown Source:8)
 at android.view.View.performClick(View.java:7441)
 at android.view.View.performClickInternal(View.java:7418)
 at android.view.View.access$3700(View.java:835)
 at android.view.View$PerformClick.run(View.java:28676)
 at android.os.Handler.handleCallback(Handler.java:938)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loopOnce(Looper.java:201)
 at android.os.Looper.loop(Looper.java:288)
 at android.app.ActivityThread.main(ActivityThread.java:7839)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

The suggestion we provided towards Genesys was to create your custom FileProvider and declare it in the
AndroidManifest file. This way there would be no conflicts because the file providers will have
different names

public class GenesysFileProvider extends FileProvider {} //And in the manifest you would declare this provider
<provider
 android:name=“.GenesysFileProvider”
 …
</provider>

Maybe anyone has any ideas/recommendations?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.