frostney / react-native-create-library

:notebook: Command line tool to create a React Native library with a single command
MIT License
1.45k stars 113 forks source link

Old React Native gradle dependency #85

Closed Ligia-Andreica closed 6 years ago

Ligia-Andreica commented 6 years ago

Thank you for a great library!

The build gradle script has the following RN dependency: compile 'com.facebook.react:react-native:+' which defaults to an old RN version: 0.20.1 (latest version available on maven central).

maicki commented 6 years ago

Hey @Ligia-Andreica, you have to add an entry for the local React Native maven directory to build.gradle, what the generator should do by default. Be sure to add it to the "allprojects" block, above other maven repositories:

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

Also a good overview about the steps is in here: https://facebook.github.io/react-native/docs/integration-with-existing-apps

Ligia-Andreica commented 6 years ago

I wonder if I missed something, because this it my generated gradle.build file content:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
    }
}

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    lintOptions {
        abortOnError false
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.facebook.react:react-native:+'
}

Manually adding the allprojects configuration fixes the issue.

maicki commented 6 years ago

@Ligia-Andreica Please use master as with the current released version it creates an invalid gradle.build that you are seeing.