Skip to content

fix: auto-configure local Maven repo for shared-storage dependency#1272

Open
roidayan1 wants to merge 1 commit intoreact-native-async-storage:mainfrom
roidayan1:fix/android-local-maven-repo-resolution
Open

fix: auto-configure local Maven repo for shared-storage dependency#1272
roidayan1 wants to merge 1 commit intoreact-native-async-storage:mainfrom
roidayan1:fix/android-local-maven-repo-resolution

Conversation

@roidayan1
Copy link
Copy Markdown

Summary

  • Auto-configure the local Maven repository for shared-storage in the library's own build.gradle
  • Remove the manual Android setup step from README, migration guide, and example project

Problem

The org.asyncstorage.shared_storage:storage-android:1.0.0 artifact is bundled in android/local_repo/ but is not published to Maven Central or Google's Maven repository. This means every consumer must manually add the local Maven URL to their root android/build.gradle:

allprojects {
    repositories {
        maven {
            url = uri(project(":react-native-async-storage_async-storage").file("local_repo"))
        }
    }
}

This is easy to miss during installation and causes confusing Gradle build failures (Could not find org.asyncstorage.shared_storage:storage-android:1.0.0).

Fix

Add the local Maven repository configuration directly to the library's packages/async-storage/android/build.gradle:

  1. Module-level: maven { url("${project.projectDir}/local_repo") } — resolves the dependency for the module itself
  2. rootProject.allprojects: maven { url("${rootDir}/../node_modules/...") } — ensures transitive resolution across the entire Android build

This makes it work out of the box — no manual setup required.

Changes

  • packages/async-storage/android/build.gradle — add local Maven repo configuration
  • README.md — remove manual Android setup section
  • docs/migration-to-3.md — remove manual Android setup instructions
  • examples/react-native/android/build.gradle — remove manual repo config (now inherited)

Patch (for patch-package users)

Until this is released, you can use this patch with patch-package:

@react-native-async-storage+async-storage+3.0.1.patch
diff --git a/node_modules/@react-native-async-storage/async-storage/android/build.gradle b/node_modules/@react-native-async-storage/async-storage/android/build.gradle
index 4f80202..19613fa 100644
--- a/node_modules/@react-native-async-storage/async-storage/android/build.gradle
+++ b/node_modules/@react-native-async-storage/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"

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
@roidayan1 roidayan1 requested review from krizzu and tido64 as code owners March 22, 2026 22:06
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 22, 2026

⚠️ No Changeset found

Latest commit: a7cdd18

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant