The following instructions are for the next
version 2.0.0-experimental.x
, which supports react-native 0.40.0
or higher. To use it specify "react-native-navigation": "next"
in your package.json dependencies. Bear in mind, as the name of the version suggests - this version is experimental and under heavy development.
- Make sure you are using react-native version 0.40.0 or above
-
Add the following to your
settings.gradle
file located in theandroid
folder:include ':react-native-navigation' project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/android/app/')
-
Update project dependencies in
build.gradle
underapp
folder.dependencies { compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" compile project(':react-native-navigation') }
-
Your
MainActivity
should extendcom.reactnativenavigation.controllers.SplashActivity
instead ofReactActivity
. If you have anyreact-native
related methods in yourMainActivity
you can safely delete them. -
Update the MainApplication file and update the
Application
element inAndroidManifest.xml
import com.reactnativenavigation.NavigationApplication; public class MainApplication extends NavigationApplication { }
<application android:name=".MainApplication" ... />
-
Implement
isDebug
andcreateAdditionalReactPackages
methodsimport com.reactnativenavigation.NavigationApplication; public class MyApplication extends NavigationApplication { @Override public boolean isDebug() { // Make sure you are using BuildConfig from your own application return BuildConfig.DEBUG; } @Override public List<ReactPackage> createAdditionalReactPackages() { // Add the packages you require here. // No need to add RnnPackage and MainReactPackage return null; } }
-
Run
react-native start