Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fileprovider-conflict.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@react-native-documents/viewer": patch
---

fix: use unique FileProvider name to prevent conflict with other FileProvider
4 changes: 2 additions & 2 deletions packages/document-viewer/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<application>
<!-- android:authorities needs to be unique to an app, so we cannot hardcode it -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.reactnativedocumentviewer.fileprovider"
android:name=".DocumentViewerFileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.reactnativedocumentviewer;

import androidx.core.content.FileProvider

/**
* Empty subclass of [FileProvider] used so this library's provider has a unique
* [android:name] in the manifest. That prevents the manifest merger from merging
* this provider with another library's FileProvider,
* which would cause an "Attribute provider@authorities value=... is also present at..."
* conflict.
*/
class DocumentViewerFileProvider : FileProvider()
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class RNDocumentViewerModule(reactContext: ReactApplicationContext) : NativeDocu
// Package name may not be the same as applicationId but usually is.
// Also see document-viewer/android/src/main/AndroidManifest.xml
val applicationId = androidApplicationId ?: reactApplicationContext.packageName
val authority = "$applicationId.reactnativedocumentviewer.fileprovider"
val authority = "$applicationId.fileprovider"
val uri = Uri.parse(bookmarkOrUri)
val uriPath = uri.path ?: throw IllegalArgumentException("file:// uri must have a path")
val fileUri = FileProvider.getUriForFile(
Expand Down