From a7cdd188011bc6a222075c0025d9c7b444d58b37 Mon Sep 17 00:00:00 2001 From: Roi Dayan Date: Mon, 23 Mar 2026 00:06:29 +0200 Subject: [PATCH] fix: auto-configure local Maven repo for shared-storage dependency The shared-storage artifact (org.asyncstorage.shared_storage:storage-android) is not published to Maven Central, so Android builds fail unless the consumer manually adds the local_repo Maven URL to their root build.gradle. Move this configuration into the library's own build.gradle so it works automatically. This removes the manual Android setup step from installation. - Add local_repo Maven URL to module repositories - Add rootProject.allprojects hook for transitive resolution - Remove manual Android setup instructions from README and migration guide - Remove manual repo config from example project --- README.md | 17 ----------------- docs/migration-to-3.md | 15 +-------------- examples/react-native/android/build.gradle | 3 --- packages/async-storage/android/build.gradle | 11 +++++++++++ 4 files changed, 12 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index bc51b358..1e1ffca0 100644 --- a/README.md +++ b/README.md @@ -46,23 +46,6 @@ npm install @react-native-async-storage/async-storage yarn add @react-native-async-storage/async-storage ``` -### Android - -Inside your `android/build.gradle(.kts)` file, add link to local maven repo: - -```groovy -allprojects { - repositories { - // ... others like google(), mavenCentral() - - maven { - url = uri(project(":react-native-async-storage_async-storage").file("local_repo")) - // or uri("path/to/node_modules/@react-native-async-storage/async-storage/android/local_repo") - } - } -} -``` - ### iOS/macOS Install cocoapods dependencies: diff --git a/docs/migration-to-3.md b/docs/migration-to-3.md index 7ab492b6..8de3c096 100644 --- a/docs/migration-to-3.md +++ b/docs/migration-to-3.md @@ -26,20 +26,7 @@ Other components: ### Installation changes -Android requires a local Maven repository to be added to your `android/build.gradle(.kts)`: - -```groovy -allprojects { - repositories { - // ... others like google(), mavenCentral() - - maven { - url = uri(project(":react-native-async-storage_async-storage").file("local_repo")) - // or uri("path/to/node_modules/@react-native-async-storage/async-storage/android/local_repo") - } - } -} -``` +No additional Android setup is required — the local Maven repository for `shared-storage` is configured automatically by the library's `build.gradle`. ### `AsyncStorage` is now instance-based diff --git a/examples/react-native/android/build.gradle b/examples/react-native/android/build.gradle index 487a730a..602e4cc7 100644 --- a/examples/react-native/android/build.gradle +++ b/examples/react-native/android/build.gradle @@ -39,8 +39,5 @@ allprojects { }() mavenCentral() google() - maven { - url = uri(project(":react-native-async-storage_async-storage").file("local_repo")) - } } } diff --git a/packages/async-storage/android/build.gradle b/packages/async-storage/android/build.gradle index 4f80202c..19613fae 100644 --- a/packages/async-storage/android/build.gradle +++ b/packages/async-storage/android/build.gradle @@ -78,10 +78,21 @@ android { } repositories { + maven { + url("${project.projectDir}/local_repo") + } mavenCentral() google() } +rootProject.allprojects { + repositories { + maven { + url("${rootDir}/../node_modules/@react-native-async-storage/async-storage/android/local_repo") + } + } +} + dependencies { implementation "com.facebook.react:react-android" api "org.asyncstorage.shared_storage:storage-android:1.0.0"