From c95496b6a40f22bea4f6c51d8203370f5ad26649 Mon Sep 17 00:00:00 2001
From: "li.zhaoguang"
Date: Tue, 7 May 2019 17:17:12 +0800
Subject: [PATCH] =?UTF-8?q?react-native-navigation=20android=20=E7=BC=96?=
=?UTF-8?q?=E8=AF=91=E9=80=9A=E8=BF=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
android/app/build.gradle | 2 +
.../main/java/com/timepill/MainActivity.java | 11 +++---
.../java/com/timepill/MainApplication.java | 38 ++++++++++++++++++-
android/build.gradle | 3 +-
android/settings.gradle | 3 ++
package-lock.json | 10 +++++
package.json | 3 +-
7 files changed, 62 insertions(+), 8 deletions(-)
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 8b0b174..e342607 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -105,6 +105,7 @@ android {
applicationId "com.timepill"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
+ missingDimensionStrategy "RNN.reactNativeVersion", "reactNative57_5"
versionCode 1
versionName "1.0"
}
@@ -141,6 +142,7 @@ dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
+ implementation project(':react-native-navigation')
}
// Run this once to be able to run the application with BUCK
diff --git a/android/app/src/main/java/com/timepill/MainActivity.java b/android/app/src/main/java/com/timepill/MainActivity.java
index f0e10e9..a67f608 100644
--- a/android/app/src/main/java/com/timepill/MainActivity.java
+++ b/android/app/src/main/java/com/timepill/MainActivity.java
@@ -1,15 +1,16 @@
package com.timepill;
import com.facebook.react.ReactActivity;
+import com.reactnativenavigation.NavigationActivity;
-public class MainActivity extends ReactActivity {
+public class MainActivity extends NavigationActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
- @Override
- protected String getMainComponentName() {
- return "Timepill";
- }
+// @Override
+// protected String getMainComponentName() {
+// return "Timepill";
+// }
}
diff --git a/android/app/src/main/java/com/timepill/MainApplication.java b/android/app/src/main/java/com/timepill/MainApplication.java
index 1db7494..9f0c7fa 100644
--- a/android/app/src/main/java/com/timepill/MainApplication.java
+++ b/android/app/src/main/java/com/timepill/MainApplication.java
@@ -11,7 +11,43 @@ import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
-public class MainApplication extends Application implements ReactApplication {
+import com.reactnativenavigation.NavigationApplication;
+import com.reactnativenavigation.react.NavigationReactNativeHost;
+import com.reactnativenavigation.react.ReactGateway;
+
+
+public class MainApplication extends NavigationApplication {
+
+ @Override
+ protected ReactGateway createReactGateway() {
+ ReactNativeHost host = new NavigationReactNativeHost(this, isDebug(), createAdditionalReactPackages()) {
+ @Override
+ protected String getJSMainModuleName() {
+ return "index";
+ }
+ };
+ return new ReactGateway(this, isDebug(), host);
+ }
+
+ @Override
+ public boolean isDebug() {
+ return BuildConfig.DEBUG;
+ }
+
+ protected List getPackages() {
+ // Add additional packages you require here
+ // No need to add RnnPackage and MainReactPackage
+ return Arrays.asList(
+ // eg. new VectorIconsPackage()
+ );
+ }
+
+ @Override
+ public List createAdditionalReactPackages() {
+ return getPackages();
+ }
+
+
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
diff --git a/android/build.gradle b/android/build.gradle
index c6e7c7c..85c8c95 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -3,7 +3,7 @@
buildscript {
ext {
buildToolsVersion = "28.0.3"
- minSdkVersion = 16
+ minSdkVersion = 18
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
@@ -29,5 +29,6 @@ allprojects {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
+ maven { url 'https://jitpack.io' }
}
}
diff --git a/android/settings.gradle b/android/settings.gradle
index 9fc68be..9d29d46 100644
--- a/android/settings.gradle
+++ b/android/settings.gradle
@@ -1,3 +1,6 @@
rootProject.name = 'Timepill'
include ':app'
+
+include ':react-native-navigation'
+project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app/')
diff --git a/package-lock.json b/package-lock.json
index 7237404..5bb5fbc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4170,6 +4170,8 @@
},
"jest": {
"version": "24.7.1",
+ "resolved": "https://registry.npmjs.org/jest/-/jest-24.7.1.tgz",
+ "integrity": "sha512-AbvRar5r++izmqo5gdbAjTeA6uNRGoNRuj5vHB0OnDXo2DXWZJVuaObiGgtlvhKb+cWy2oYbQSfxv7Q7GjnAtA==",
"dev": true,
"requires": {
"import-local": "^2.0.0",
@@ -5867,6 +5869,8 @@
},
"metro-react-native-babel-preset": {
"version": "0.53.1",
+ "resolved": "https://registry.npmjs.org/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.53.1.tgz",
+ "integrity": "sha512-Uf8EGL8kIPhDkoSdAAysNPxPQclUS2R1QC4cwnc8bkk2f6yqGn+1CorfiY9AaqlLEth5mKQqdtRYFDTFfB9QyA==",
"dev": true,
"requires": {
"@babel/plugin-proposal-class-properties": "^7.0.0",
@@ -6839,6 +6843,8 @@
},
"react": {
"version": "16.8.3",
+ "resolved": "https://registry.npmjs.org/react/-/react-16.8.3.tgz",
+ "integrity": "sha512-3UoSIsEq8yTJuSu0luO1QQWYbgGEILm+eJl2QN/VLDi7hL+EN18M3q3oVZwmVzzBJ3DkM7RMdRwBmZZ+b4IzSA==",
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1",
@@ -6894,6 +6900,8 @@
},
"react-native": {
"version": "0.59.4",
+ "resolved": "https://registry.npmjs.org/react-native/-/react-native-0.59.4.tgz",
+ "integrity": "sha512-etnXQp9IZgC8Vj5gsxZEDP4xRjJVNIj5/BSE1WcNAONG6tu6+mDBntx1jxHInwh61WYNgoQJuQGsbN5Na59ZDw==",
"requires": {
"@babel/runtime": "^7.0.0",
"@react-native-community/cli": "^1.2.1",
@@ -7094,6 +7102,8 @@
},
"react-test-renderer": {
"version": "16.8.3",
+ "resolved": "https://registry.npmjs.org/react-test-renderer/-/react-test-renderer-16.8.3.tgz",
+ "integrity": "sha512-rjJGYebduKNZH0k1bUivVrRLX04JfIQ0FKJLPK10TAb06XWhfi4gTobooF9K/DEFNW98iGac3OSxkfIJUN9Mdg==",
"dev": true,
"requires": {
"object-assign": "^4.1.1",
diff --git a/package.json b/package.json
index 4399941..551ef20 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,8 @@
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
- "test": "jest"
+ "test": "jest",
+ "android": "cd ./android && ./gradlew app:assembleDebug && ./gradlew installDebug"
},
"dependencies": {
"react": "16.8.3",