Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch react-native-file-provider@1.1.0 for the project I'm working on.
It came to my attention the following comment in the Android official guide:
https://developer.android.com/reference/androidx/core/content/FileProvider
It is possible to use FileProvider directly instead of extending it. However, this is not reliable and will causes crashes on some devices.
So for better compatibility, I suggest the modifications below:
diff --git a/node_modules/react-native-file-provider/android/src/main/java/com/artirigo/fileprovider/MyFileProvider.java b/node_modules/react-native-file-provider/android/src/main/java/com/artirigo/fileprovider/MyFileProvider.java
new file mode 100644
index 0000000..23c735c
--- /dev/null
+++ b/node_modules/react-native-file-provider/android/src/main/java/com/artirigo/fileprovider/MyFileProvider.java
@@ -0,0 +1,5 @@
+package com.artirigo.fileprovider;
+
+import androidx.core.content.FileProvider;
+
+public class MyFileProvider extends FileProvider { }
diff --git a/node_modules/react-native-file-provider/android/src/main/java/com/artirigo/fileprovider/RNFileProviderModule.java b/node_modules/react-native-file-provider/android/src/main/java/com/artirigo/fileprovider/RNFileProviderModule.java
index a9bc7d9..8141365 100644
--- a/node_modules/react-native-file-provider/android/src/main/java/com/artirigo/fileprovider/RNFileProviderModule.java
+++ b/node_modules/react-native-file-provider/android/src/main/java/com/artirigo/fileprovider/RNFileProviderModule.java
@@ -34,7 +34,7 @@ public class RNFileProviderModule extends ReactContextBaseJavaModule {
//
File file = new File(filepath);
if (!file.exists()) throw new Exception("File does not exist");
- Uri contentUri = FileProvider.getUriForFile(this.getReactApplicationContext(), authority, file);
+ Uri contentUri = MyFileProvider.getUriForFile(this.getReactApplicationContext(), authority, file);
promise.resolve(contentUri.toString());
} catch (Exception ex) {
ex.printStackTrace();
This issue body was partially generated by patch-package.
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
react-native-file-provider@1.1.0for the project I'm working on.It came to my attention the following comment in the Android official guide:
https://developer.android.com/reference/androidx/core/content/FileProvider
So for better compatibility, I suggest the modifications below:
This issue body was partially generated by patch-package.