Skip to content

Manual Installation

Alpha edited this page Jun 22, 2022 · 3 revisions

If you do not wish to, or cannot use autolinking, manually install react-native-file-access as follows.

Android

Register project in your android/settings.gradle. (Note that the context in the following diff will vary depending on your version of React Native; just add the two lines to the end of the file.)

diff --git a/android/settings.gradle b/android/settings.gradle
index ac001d9..d7fe903 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -7,3 +7,6 @@ if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true")
     include(":ReactAndroid")
     project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid')
 }
+
+include ':react-native-file-access'
+project(':react-native-file-access').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-file-access/android')

Edit android/app/build.gradle to include the project in your app's build.

diff --git a/android/app/build.gradle b/android/app/build.gradle
index ed42bbf..63f3d27 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -266,6 +266,8 @@ dependencies {
     //noinspection GradleDynamicVersion
     implementation "com.facebook.react:react-native:+"  // From node_modules
 
+    implementation project(':react-native-file-access')
+
     implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
 
     debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {

Register the package with react native in android/app/src/main/java/[...]/MainApplication.java function getPackages(). (Path will vary based on your app's name.)

diff --git a/android/app/src/main/java/com/manualinstall/MainApplication.java b/android/app/src/main/java/com/manualinstall/MainApplication.java
index c673ffd..f7490eb 100644
--- a/android/app/src/main/java/com/manualinstall/MainApplication.java
+++ b/android/app/src/main/java/com/manualinstall/MainApplication.java
@@ -2,6 +2,7 @@ package com.manualinstall;
 
 import android.app.Application;
 import android.content.Context;
+import com.alpha0010.fs.FileAccessPackage;
 import com.facebook.react.PackageList;
 import com.facebook.react.ReactApplication;
 import com.facebook.react.ReactInstanceManager;
@@ -28,6 +29,7 @@ public class MainApplication extends Application implements ReactApplication {
           List<ReactPackage> packages = new PackageList(this).getPackages();
           // Packages that cannot be autolinked yet can be added manually here, for example:
           // packages.add(new MyReactNativePackage());
+          packages.add(new FileAccessPackage());
           return packages;
         }
 

iOS

Clone this wiki locally