From 4ce682036225126d2ec4d40309fccaa74dcc23e5 Mon Sep 17 00:00:00 2001 From: Website Deployment Script Date: Fri, 14 Oct 2016 16:00:01 +0000 Subject: [PATCH] Updated docs for next --- releases/next/docs/integration-with-existing-apps.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/releases/next/docs/integration-with-existing-apps.html b/releases/next/docs/integration-with-existing-apps.html index 916af757cb6..2fa74ab51c2 100644 --- a/releases/next/docs/integration-with-existing-apps.html +++ b/releases/next/docs/integration-with-existing-apps.html @@ -87,6 +87,7 @@ target 'NumberTileGame' 'React', :path => '../node_modules/react-native', :subspecs => [ 'Core', 'RCTText', + 'RCTNetwork', 'RCTWebSocket', # needed for debugging # Add any other subspecs you want to use in your project ] @@ -107,6 +108,7 @@ target 'swift-2048' 'React', :path => '../node_modules/react-native', :subspecs => [ 'Core', 'RCTText', + 'RCTNetwork', 'RCTWebSocket', # needed for debugging # Add any other subspecs you want to use in your project ] @@ -289,7 +291,7 @@ AppRegistry. } } ... -}

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.

Next, make sure you have the Internet permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

This is only really used in dev mode when reloading JavaScript from the development server, so you can strip this in release builds if you need to.

Add native code #

You need to add some native code in order to start the React Native runtime and get it to render something. To do this, we're going to create an Activity that creates a ReactRootView, starts a React application inside it and sets it as the main content view.

If you are targetting Android version <5, use the AppCompatActivity class from the com.android.support:appcompat package instead of Activity.

If you find out later that your app crashes due to Didn't find class "com.facebook.jni.IteratorHelper" exception, uncomment the setUseOldBridge line. See related issue on GitHub.

public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler { +}

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.

Next, make sure you have the Internet permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

This is only really used in dev mode when reloading JavaScript from the development server, so you can strip this in release builds if you need to.

Add native code #

You need to add some native code in order to start the React Native runtime and get it to render something. To do this, we're going to create an Activity that creates a ReactRootView, starts a React application inside it and sets it as the main content view.

If you are targetting Android version <5, use the AppCompatActivity class from the com.android.support:appcompat package instead of Activity.

public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler { private ReactRootView mReactRootView; private ReactInstanceManager mReactInstanceManager; @@ -305,8 +307,7 @@ AppRegistry. .addPackage(new MainReactPackage()) .setUseDeveloperSupport(BuildConfig.DEBUG) .setInitialLifecycleState(LifecycleState.RESUMED) - //.setUseOldBridge(true) // uncomment this line if your app crashes - .build(); + .build(); mReactRootView.startReactApplication(mReactInstanceManager, "HelloWorld", null); setContentView(mReactRootView);