React-Native-Local-Resource icon indicating copy to clipboard operation
React-Native-Local-Resource copied to clipboard

Android build fails after including this library because of "provided" dependency in build.gradle

Open finsterwalder opened this issue 3 years ago • 2 comments

After including the library as a dependency, we get the following error during our android build:

A problem occurred evaluating project ':react-native-local-resource'.

Could not find method provided() for arguments [com.facebook.react:react-native:+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Your build.gradle file includes a "provided" dependency. I found references, that this is deprecated and should probably be replaced by compileOnly.

finsterwalder avatar Jan 31 '23 14:01 finsterwalder

Hey @finsterwalder have you managed to find a workaround for this?

yotam-frid avatar Feb 22 '23 07:02 yotam-frid

I used patch-package to apply this patch. Worked for me:

diff --git a/node_modules/react-native-local-resource/android/build.gradle b/node_modules/react-native-local-resource/android/build.gradle
index ae0b6dc..24520a2 100644
--- a/node_modules/react-native-local-resource/android/build.gradle
+++ b/node_modules/react-native-local-resource/android/build.gradle
@@ -36,6 +36,6 @@ repositories {
 }
 
 dependencies {
-    provided 'com.facebook.react:react-native:+'
-    compile group: 'commons-io', name: 'commons-io', version: '2.6'
+    compileOnly 'com.facebook.react:react-native:+'
+    implementation group: 'commons-io', name: 'commons-io', version: '2.6'
 }

fullStackOasis avatar Apr 10 '23 19:04 fullStackOasis