I want to create one react-native library which will be consumed by existing Android projects. Facebook documentation says that we should add below lines in Android projects build.gradle file.

allprojects { repositories { ... maven { // All of React Native (JS, Android binaries) is installed from npm url "$rootDir/node_modules/react-native/android" } } ... }

Now, My problem is that android project might use multiple react-native projects and each of them might be having different versions of react-native. e.g. AndroidProject "project1" might include two react-native projects: proj1 and proj2. Proj1 is written with react-native version 0.23.1 while proj2 is written with react-native version 0.29.1.

How can I specifically tell my android project to use different versions of react-native for these two projects?

I thought that, I can mention project specific dependency by adding below lines in root project build.gradle file,

project(":proj1") { repositories { maven { // All of React Native (JS, Android binaries) is installed from npm url "$rootDir/proj1/node_modules/react-native/android" } } } project(":proj2") { repositories { maven { // All of React Native (JS, Android binaries) is installed from npm url "$rootDir/proj2/node_modules/react-native/android" } } }

but, it appears that repositories can't be mentioned like this. Even, if I do, it needs similar dependency for root project as well, because, project(":app") depends on proj1 and proj2 and to build my project, I have to mention react-native url for project(":app") as well.

Has anyone already solved similar problem? Any suggestion on how to handle this?

Please let me know if more information is required.