简体   繁体   English

如何在模块中添加React Native依赖项?

[英]How to add react native dependency in module?

When I add the react-native dependency in my app module, it's working, but when I am trying to add it on different module I am getting 当我在我的应用模块中添加react-native依赖关系时,它正在工作,但是当我尝试将其添加到其他模块中时,我得到了

Error:(49, 13) Failed to resolve: com.facebook.react:react-native:0.49.3 错误:(49,13)无法解决:com.facebook.react:react-native:0.49.3

Root Gradle: 根摇篮:

allprojects {
    repositories {
        jcenter()
        maven {
            url "$projectDir/../android/node_modules/react-native/android"
        }
    }
}

I think about moving node_modules to my module folder, but is a there better solution? 我考虑将node_modules移到我的模块文件夹中,但是有更好的解决方案吗?

So I solved this,moving node_modules to my platform module and changing gradle files like this. 所以我解决了这个问题,将node_modules移到我的platform模块并像这样更改gradle文件。

Root Build.gradle 根构建等级

allprojects {
    repositories {
        jcenter()
        maven {
            url "$projectDir/../../../platform/android/node_modules/react-native/android"
        }
    }
}

Platform Build.gradle 平台构建

repositories {
    mavenCentral()
    maven {
        url "$projectDir/android/node_modules/react-native/android"
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM