Skip to content Skip to sidebar Skip to footer

How To Configure React Native Android Library To Use Npm Installed React-native?

I'm writing an android library, need to call ReactInstanceManager.onHostResume, my build.gradle file content is: apply plugin: 'com.android.library' android { compileSdkVersio

Solution 1:

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.


Post a Comment for "How To Configure React Native Android Library To Use Npm Installed React-native?"