Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile 'com.facebook.react:react-native:+' defaults to 0.20.1 #12309

Closed
Brian-Kaplan opened this issue Feb 9, 2017 · 9 comments
Closed

compile 'com.facebook.react:react-native:+' defaults to 0.20.1 #12309

Brian-Kaplan opened this issue Feb 9, 2017 · 9 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@Brian-Kaplan
Copy link

Brian-Kaplan commented Feb 9, 2017

Description

Following the integration steps outlined here...
https://facebook.github.io/react-native/docs/integration-with-existing-apps.html

The version of React Native that I get as an External Library is 0.20.1 (Seeing this in android studio)

My package.json says the version is 0.41.2

Please help me get the right version... I don't have access to new classes that were added between 0.20.1 and 0.41.2

I thought maybe the .gradle/cache was the issue here but it is not

The last released version in Maven Repo is 0.20.1
For some reason this definition in my projects build.gradle is not finding the jar. I have double - triple checked this path and its correct...

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

So this

compile "com.facebook.react:react-native:+" // From node_modules.

is defaulting to the Maven Repo 0.20.1 instead of my local node_modules installed jars. I have verified that that the local version i have in node_modules is 0.41.2

What am i missing here...?

Reproduction

Follow the integration instructions for react native in the docs

Solution

Make sure the maven url definition in the project build.gradle is inside the allProjects{} block

Additional Information

  • React Native version: package.json says 0.41.2
  • Platform: Android
  • Operating System: MacOS
@Brian-Kaplan
Copy link
Author

So apparently there is a HUGE difference between putting the maven def inside the buildscript{} vs allProjects{} block.

Would be nice if the integration doc reiterated this as being especially important.

@lacker
Copy link
Contributor

lacker commented Feb 10, 2017

Which part in the integration doc are you talking about exactly? Or, better, would you be interested in sending a pull request to improve it?

@Brian-Kaplan
Copy link
Author

https://facebook.github.io/react-native/docs/integration-with-existing-apps.html

From above...

In your project's build.gradle file add an entry for the local React Native maven directory:

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

Make sure that the path is correct! You shouldn’t run into any “Failed to resolve: com.facebook.react:react-native:0.x.x" errors after running Gradle sync in Android Studio.

I think adding something that says...

Note: be sure to add this maven url to the allProjects block of your build.gradle.

The code example does show it inside the allProjects block but It's a very small detail that can be easily missed. Since this doc is talking about integrating react native with existing apps, it's possible that the build.gradle your'e putting this code in is huge (like the one I was just working with) and have multiple blocks with maven defs in different places. Just a nit that I think will help people not waste time trying to integrate RN into their apps. There are many other hurdles one must solve and adding a simple note could make a world of difference.

I would love to make a PR for this but I don't think those docs are in this repo?

@lacker
Copy link
Contributor

lacker commented Feb 10, 2017

Ah I am super excited that you would love to make a PR for this ;-) Those docs are indeed in this repo, check out https://github.com/facebook/react-native/blob/master/docs/IntegrationWithExistingApps.md . If you @ me in your PR then I will look at it real quick!

@alexblack
Copy link

alexblack commented Feb 19, 2017

I hit this problem too, but I'm not sure what the solution is?

I've got

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

@alexblack
Copy link

alexblack commented Feb 19, 2017

I got this fixed by changing to reference a specific react-native version:

compile 'com.facebook.react:react-native:0.41.2'

Then I'd get an error when compiling, unable to find it. Then changed to:

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

From

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

@humblehacker
Copy link

I also got it working with @alexblack's change. But I also had accidentally typed single rather than double quotes, which was preventing the expansion of $rootDir.

@joshuapinter
Copy link
Contributor

@alexblack Yes, thank you for this! It's important to make sure your path is correct. I copied from the React Native docs thinking it would just work but I had to make the same change as you since I don't have an Android subdirectory.

Thanks for the pointer.

@hramos hramos added the Icebox label Jul 31, 2017
@hramos
Copy link
Contributor

hramos commented Jul 31, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants