How to configure react native android library to use npm installed react-native?

后端 未结 1 2042
萌比男神i
萌比男神i 2021-02-15 03:43

I\'m writing an android library, need to call ReactInstanceManager.onHostResume, my build.gradle file content is:

apply plugin: \'com.android.library\'

android          


        
1条回答
  •  北海茫月
    2021-02-15 04:30

    Resolved a while ago as well... I created a library using react-native-create-library. The latest version maven provides is 0.20.1, which is a little old for today's react-native versions. So I installed the RN version I needed into the node_modules folder of my library

    npm install react-native@0.46.1

    And in build.gradle

    repositories {
        maven {
            // All of React Native (JS, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        jcenter()
    }
    //
    dependencies {
        compile 'com.android.support:appcompat-v7:23.0.1'
        compile "com.facebook.react:react-native:+"
    }
    

    This way you don't need to keep your library inside of your master project in order to build and check your syntax.

    0 讨论(0)
提交回复
热议问题