From 75850b9014fe06793ca20edd2a26c2484d73bcdf Mon Sep 17 00:00:00 2001 From: GingerBear Date: Tue, 5 Sep 2017 10:51:51 -0700 Subject: [PATCH] Update Android Guide for Integration With Existing Apps Summary: I was trying to follow the instruction on http://facebook.github.io/react-native/docs/integration-with-existing-apps.html to integrate react native into existing android app, but failed. After hours of google/stackoverflow, I finally get it running. I am submitting this pr the list the diffs in the guide so that other developer won't fell into the same issues. - create an example android project - follow the guide in the pr to integrate react-native into the example android project - make sure it runs without error Closes https://github.com/facebook/react-native/pull/15813 Differential Revision: D5767573 Pulled By: hramos fbshipit-source-id: 805165a64b6db2aa2de936ad8f6a8a3d2fedd7c4 --- docs/IntegrationWithExistingApps.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/IntegrationWithExistingApps.md b/docs/IntegrationWithExistingApps.md index c3cef9c48..4f543aa3a 100644 --- a/docs/IntegrationWithExistingApps.md +++ b/docs/IntegrationWithExistingApps.md @@ -157,9 +157,11 @@ Go to the root directory for your project and create a new `package.json` file w Next, you will install the `react` and `react-native` packages. Open a terminal or command prompt, then navigate to the root directory for your project and type the following commands: ``` -$ npm install --save react react-native +$ npm install --save react@16.0.0-beta.5 react-native ``` +> Make sure you use the same React version as specified in the [React Native package.json](https://github.com/facebook/react-native/blob/master/package.json) for your release. This will only be necessary as long as React Native depends on a pre-release version of React. + This will create a new `/node_modules` folder in your project's root directory. This folder stores all the JavaScript dependencies required to build your project. @@ -542,6 +544,7 @@ Add the React Native dependency to your app's `build.gradle` file: ``` dependencies { + compile 'com.android.support:appcompat-v7:23.0.1' ... compile "com.facebook.react:react-native:+" // From node_modules. } @@ -557,7 +560,7 @@ allprojects { ... maven { // All of React Native (JS, Android binaries) is installed from npm - url "$rootDir/node_modules/react-native/android" + url "$rootDir/../node_modules/react-native/android" } } ... @@ -738,7 +741,7 @@ protected void onDestroy() { super.onDestroy(); if (mReactInstanceManager != null) { - mReactInstanceManager.onHostDestroy(); + mReactInstanceManager.onHostDestroy(this); } } ```