Browse Source

fixing example project

Daniel Zlotin 8 years ago
parent
commit
8dea566e00

+ 4
- 65
example/android/app/build.gradle View File

@@ -2,65 +2,6 @@ apply plugin: "com.android.application"
2 2
 
3 3
 import com.android.build.OutputFile
4 4
 
5
-/**
6
- * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7
- * and bundleReleaseJsAndAssets).
8
- * These basically call `react-native bundle` with the correct arguments during the Android build
9
- * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10
- * bundle directly from the development server. Below you can see all the possible configurations
11
- * and their defaults. If you decide to add a configuration block, make sure to add it before the
12
- * `apply from: "react.gradle"` line.
13
- *
14
- * project.ext.react = [
15
- *   // the name of the generated asset file containing your JS bundle
16
- *   bundleAssetName: "index.android.bundle",
17
- *
18
- *   // the entry file for bundle generation
19
- *   entryFile: "index.android.js",
20
- *
21
- *   // whether to bundle JS and assets in debug mode
22
- *   bundleInDebug: false,
23
- *
24
- *   // whether to bundle JS and assets in release mode
25
- *   bundleInRelease: true,
26
- *
27
- *   // whether to bundle JS and assets in another build variant (if configured).
28
- *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29
- *   // The configuration property can be in the following formats
30
- *   //         'bundleIn${productFlavor}${buildType}'
31
- *   //         'bundleIn${buildType}'
32
- *   // bundleInFreeDebug: true,
33
- *   // bundleInPaidRelease: true,
34
- *   // bundleInBeta: true,
35
- *
36
- *   // the root of your project, i.e. where "package.json" lives
37
- *   root: "../../",
38
- *
39
- *   // where to put the JS bundle asset in debug mode
40
- *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
41
- *
42
- *   // where to put the JS bundle asset in release mode
43
- *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
44
- *
45
- *   // where to put drawable resources / React Native assets, e.g. the ones you use via
46
- *   // require('./image.png')), in debug mode
47
- *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
48
- *
49
- *   // where to put drawable resources / React Native assets, e.g. the ones you use via
50
- *   // require('./image.png')), in release mode
51
- *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
52
- *
53
- *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
54
- *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
55
- *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
56
- *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
57
- *   // for example, you might want to remove it from here.
58
- *   inputExcludes: ["android/**", "ios/**"]
59
- * ]
60
- */
61
-
62
-apply from: "react.gradle"
63
-
64 5
 /**
65 6
  * Set this to true to create two separate APKs instead of one:
66 7
  *   - An APK that only works on ARM devices
@@ -78,12 +19,12 @@ def enableProguardInReleaseBuilds = false
78 19
 
79 20
 android {
80 21
     compileSdkVersion 23
81
-    buildToolsVersion "23.0.1"
22
+    buildToolsVersion "23.0.3"
82 23
 
83 24
     defaultConfig {
84 25
         applicationId "com.example"
85 26
         minSdkVersion 16
86
-        targetSdkVersion 22
27
+        targetSdkVersion 23
87 28
         versionCode 1
88 29
         versionName "1.0"
89 30
         ndk {
@@ -109,7 +50,7 @@ android {
109 50
         variant.outputs.each { output ->
110 51
             // For each separate APK per architecture, set a unique version code as described here:
111 52
             // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
112
-            def versionCodes = ["armeabi-v7a":1, "x86":2]
53
+            def versionCodes = ["armeabi-v7a": 1, "x86": 2]
113 54
             def abi = output.getFilter(OutputFile.ABI)
114 55
             if (abi != null) {  // null for the universal-debug, universal-release variants
115 56
                 output.versionCodeOverride =
@@ -123,7 +64,5 @@ dependencies {
123 64
     compile fileTree(dir: 'libs', include: ['*.jar'])
124 65
     compile 'com.android.support:appcompat-v7:23.0.1'
125 66
     compile 'com.facebook.react:react-native:+'
126
-        debugCompile project(path: ':react-native-navigation', configuration: 'libraryDebug')
127
-        releaseCompile project(path: ':react-native-navigation', configuration: 'libraryRelease')
128
-//    compile project(':react-native-navigation')
67
+    compile project(':react-native-navigation')
129 68
 }

+ 0
- 97
example/android/app/react.gradle View File

@@ -1,97 +0,0 @@
1
-import org.apache.tools.ant.taskdefs.condition.Os
2
-
3
-def config = project.hasProperty("react") ? project.react : [];
4
-
5
-def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
6
-def entryFile = config.entryFile ?: "index.android.js"
7
-
8
-// because elvis operator
9
-def elvisFile(thing) {
10
-    return thing ? file(thing) : null;
11
-}
12
-
13
-def reactRoot = elvisFile(config.root) ?: file("../../")
14
-def inputExcludes = config.inputExcludes ?: ["android/**", "ios/**"]
15
-
16
-void runBefore(String dependentTaskName, Task task) {
17
-    Task dependentTask = tasks.findByPath(dependentTaskName);
18
-    if (dependentTask != null) {
19
-        dependentTask.dependsOn task
20
-    }
21
-}
22
-
23
-gradle.projectsEvaluated {
24
-    // Grab all build types and product flavors
25
-    def buildTypes = android.buildTypes.collect { type -> type.name }
26
-    def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
27
-
28
-    // When no product flavors defined, use empty
29
-    if (!productFlavors) productFlavors.add('')
30
-
31
-    productFlavors.each { productFlavorName ->
32
-        buildTypes.each { buildTypeName ->
33
-            // Create variant and target names
34
-            def targetName = "${productFlavorName.capitalize()}${buildTypeName.capitalize()}"
35
-            def targetPath = productFlavorName ?
36
-                    "${productFlavorName}/${buildTypeName}" :
37
-                    "${buildTypeName}"
38
-
39
-            // React js bundle directories
40
-            def jsBundleDirConfigName = "jsBundleDir${targetName}"
41
-            def jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ?:
42
-                    file("$buildDir/intermediates/assets/${targetPath}")
43
-
44
-            def resourcesDirConfigName = "resourcesDir${targetName}"
45
-            def resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?:
46
-                    file("$buildDir/intermediates/res/merged/${targetPath}")
47
-            def jsBundleFile = file("$jsBundleDir/$bundleAssetName")
48
-
49
-            // Bundle task name for variant
50
-            def bundleJsAndAssetsTaskName = "bundle${targetName}JsAndAssets"
51
-
52
-            def currentBundleTask = tasks.create(
53
-                    name: bundleJsAndAssetsTaskName,
54
-                    type: Exec) {
55
-                group = "react"
56
-                description = "bundle JS and assets for ${targetName}."
57
-
58
-                // Create dirs if they are not there (e.g. the "clean" task just ran)
59
-                doFirst {
60
-                    jsBundleDir.mkdirs()
61
-                    resourcesDir.mkdirs()
62
-                }
63
-
64
-                // Set up inputs and outputs so gradle can cache the result
65
-                inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
66
-                outputs.dir jsBundleDir
67
-                outputs.dir resourcesDir
68
-
69
-                // Set up the call to the react-native cli
70
-                workingDir reactRoot
71
-
72
-                // Set up dev mode
73
-                def devEnabled = !targetName.toLowerCase().contains("release")
74
-                if (Os.isFamily(Os.FAMILY_WINDOWS)) {
75
-                    commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
76
-                            "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
77
-                } else {
78
-                    commandLine "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
79
-                            "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
80
-                }
81
-
82
-                enabled config."bundleIn${targetName}" ||
83
-                    config."bundleIn${buildTypeName.capitalize()}" ?:
84
-                            targetName.toLowerCase().contains("release")
85
-            }
86
-
87
-            // Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process
88
-            currentBundleTask.dependsOn("merge${targetName}Resources")
89
-            currentBundleTask.dependsOn("merge${targetName}Assets")
90
-
91
-            runBefore("processArmeabi-v7a${targetName}Resources", currentBundleTask)
92
-            runBefore("processX86${targetName}Resources", currentBundleTask)
93
-            runBefore("processUniversal${targetName}Resources", currentBundleTask)
94
-            runBefore("process${targetName}Resources", currentBundleTask)
95
-        }
96
-    }
97
-}

+ 7
- 6
example/android/app/src/main/AndroidManifest.xml View File

@@ -1,17 +1,18 @@
1 1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
-          package="com.example">
2
+    package="com.example">
3 3
 
4 4
     <uses-permission android:name="android.permission.INTERNET" />
5 5
 
6 6
     <application
7
-        android:allowBackup="true"
8
-        android:label="@string/app_name"
7
+        android:name=".MyApplication"
8
+        android:allowBackup="false"
9 9
         android:icon="@mipmap/ic_launcher"
10
+        android:label="@string/app_name"
10 11
         android:theme="@style/AppTheme">
11 12
         <activity
12
-            android:name=".MainActivity"
13
-            android:label="@string/app_name"
14
-            android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
13
+            android:name=".MyActivity"
14
+            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
15
+            android:label="@string/app_name">
15 16
             <intent-filter>
16 17
                 <action android:name="android.intent.action.MAIN" />
17 18
                 <category android:name="android.intent.category.LAUNCHER" />

+ 0
- 18
example/android/app/src/main/java/com/example/MainActivity.java View File

@@ -1,18 +0,0 @@
1
-package com.example;
2
-
3
-
4
-import com.reactnativenavigation.activities.RootActivity;
5
-
6
-public class MainActivity extends RootActivity {
7
-
8
-    @Override
9
-    protected String getMainComponentName() {
10
-        return "App";
11
-    }
12
-
13
-    @Override
14
-    protected void onPause() {
15
-        super.onPause();
16
-        finish();
17
-    }
18
-}

+ 9
- 0
example/android/app/src/main/java/com/example/MyActivity.java View File

@@ -0,0 +1,9 @@
1
+package com.example;
2
+
3
+
4
+import android.view.View;
5
+
6
+import com.reactnativenavigation.controllers.SplashActivity;
7
+
8
+public class MyActivity extends SplashActivity {
9
+}

+ 21
- 0
example/android/app/src/main/java/com/example/MyApplication.java View File

@@ -0,0 +1,21 @@
1
+package com.example;
2
+
3
+import android.support.annotation.Nullable;
4
+
5
+import com.facebook.react.ReactPackage;
6
+import com.reactnativenavigation.NavigationApplication;
7
+
8
+import java.util.List;
9
+
10
+public class MyApplication extends NavigationApplication {
11
+    @Override
12
+    public boolean isDebug() {
13
+        return BuildConfig.DEBUG;
14
+    }
15
+
16
+    @Nullable
17
+    @Override
18
+    public List<ReactPackage> createAdditionalReactPackages() {
19
+        return null;
20
+    }
21
+}

+ 2
- 2
example/android/build.gradle View File

@@ -5,7 +5,7 @@ buildscript {
5 5
         jcenter()
6 6
     }
7 7
     dependencies {
8
-        classpath 'com.android.tools.build:gradle:1.3.1'
8
+        classpath 'com.android.tools.build:gradle:2.1.3'
9 9
 
10 10
         // NOTE: Do not place your application dependencies here; they belong
11 11
         // in the individual module build.gradle files
@@ -18,7 +18,7 @@ allprojects {
18 18
         jcenter()
19 19
         maven {
20 20
             // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
21
-            url "$projectDir/../../node_modules/react-native/android"
21
+            url "$rootDir/../node_modules/react-native/android"
22 22
         }
23 23
     }
24 24
 }

BIN
example/android/gradle/wrapper/gradle-wrapper.jar View File


+ 2
- 1
example/android/gradle/wrapper/gradle-wrapper.properties View File

@@ -1,5 +1,6 @@
1
+#Thu Sep 15 09:59:50 IDT 2016
1 2
 distributionBase=GRADLE_USER_HOME
2 3
 distributionPath=wrapper/dists
3 4
 zipStoreBase=GRADLE_USER_HOME
4 5
 zipStorePath=wrapper/dists
5
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
6
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip

+ 26
- 26
example/android/gradlew View File

@@ -6,12 +6,30 @@
6 6
 ##
7 7
 ##############################################################################
8 8
 
9
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10
-DEFAULT_JVM_OPTS=""
9
+# Attempt to set APP_HOME
10
+# Resolve links: $0 may be a link
11
+PRG="$0"
12
+# Need this for relative symlinks.
13
+while [ -h "$PRG" ] ; do
14
+    ls=`ls -ld "$PRG"`
15
+    link=`expr "$ls" : '.*-> \(.*\)$'`
16
+    if expr "$link" : '/.*' > /dev/null; then
17
+        PRG="$link"
18
+    else
19
+        PRG=`dirname "$PRG"`"/$link"
20
+    fi
21
+done
22
+SAVED="`pwd`"
23
+cd "`dirname \"$PRG\"`/" >/dev/null
24
+APP_HOME="`pwd -P`"
25
+cd "$SAVED" >/dev/null
11 26
 
12 27
 APP_NAME="Gradle"
13 28
 APP_BASE_NAME=`basename "$0"`
14 29
 
30
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31
+DEFAULT_JVM_OPTS=""
32
+
15 33
 # Use the maximum available, or set MAX_FD != -1 to use that value.
16 34
 MAX_FD="maximum"
17 35
 
@@ -30,6 +48,7 @@ die ( ) {
30 48
 cygwin=false
31 49
 msys=false
32 50
 darwin=false
51
+nonstop=false
33 52
 case "`uname`" in
34 53
   CYGWIN* )
35 54
     cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
40 59
   MINGW* )
41 60
     msys=true
42 61
     ;;
62
+  NONSTOP* )
63
+    nonstop=true
64
+    ;;
43 65
 esac
44 66
 
45
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
46
-if $cygwin ; then
47
-    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48
-fi
49
-
50
-# Attempt to set APP_HOME
51
-# Resolve links: $0 may be a link
52
-PRG="$0"
53
-# Need this for relative symlinks.
54
-while [ -h "$PRG" ] ; do
55
-    ls=`ls -ld "$PRG"`
56
-    link=`expr "$ls" : '.*-> \(.*\)$'`
57
-    if expr "$link" : '/.*' > /dev/null; then
58
-        PRG="$link"
59
-    else
60
-        PRG=`dirname "$PRG"`"/$link"
61
-    fi
62
-done
63
-SAVED="`pwd`"
64
-cd "`dirname \"$PRG\"`/" >&-
65
-APP_HOME="`pwd -P`"
66
-cd "$SAVED" >&-
67
-
68 67
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 68
 
70 69
 # Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
90 89
 fi
91 90
 
92 91
 # Increase the maximum file descriptors if we can.
93
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
92
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
94 93
     MAX_FD_LIMIT=`ulimit -H -n`
95 94
     if [ $? -eq 0 ] ; then
96 95
         if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
114 113
 if $cygwin ; then
115 114
     APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 115
     CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116
+    JAVACMD=`cygpath --unix "$JAVACMD"`
117 117
 
118 118
     # We build the pattern for arguments to be converted via cygpath
119 119
     ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`

+ 4
- 4
example/android/gradlew.bat View File

@@ -8,14 +8,14 @@
8 8
 @rem Set local scope for the variables with windows NT shell
9 9
 if "%OS%"=="Windows_NT" setlocal
10 10
 
11
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12
-set DEFAULT_JVM_OPTS=
13
-
14 11
 set DIRNAME=%~dp0
15 12
 if "%DIRNAME%" == "" set DIRNAME=.
16 13
 set APP_BASE_NAME=%~n0
17 14
 set APP_HOME=%DIRNAME%
18 15
 
16
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17
+set DEFAULT_JVM_OPTS=
18
+
19 19
 @rem Find java.exe
20 20
 if defined JAVA_HOME goto findJavaFromJavaHome
21 21
 
@@ -46,7 +46,7 @@ echo location of your Java installation.
46 46
 goto fail
47 47
 
48 48
 :init
49
-@rem Get command-line arguments, handling Windowz variants
49
+@rem Get command-line arguments, handling Windows variants
50 50
 
51 51
 if not "%OS%" == "Windows_NT" goto win9xME_args
52 52
 if "%@eval[2+2]" == "4" goto 4NT_args

+ 2
- 1
example/package.json View File

@@ -3,7 +3,8 @@
3 3
   "version": "0.0.1",
4 4
   "private": true,
5 5
   "scripts": {
6
-    "start": "node node_modules/react-native/local-cli/cli.js start"
6
+    "start": "watchman watch-del-all && (adb reverse tcp:8081 tcp: 8081 || true) && node node_modules/react-native/local-cli/cli.js start",
7
+    "xcode": "open ios/example.xcodeproj"
7 8
   },
8 9
   "dependencies": {
9 10
     "react-native": "0.31.0",

+ 0
- 15
example/src/app.js View File

@@ -1,8 +1,3 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  AppRegistry,
4
-  View
5
-} from 'react-native';
6 1
 import {Navigation} from 'react-native-navigation';
7 2
 
8 3
 // screen related book keeping
@@ -21,15 +16,5 @@ Navigation.startSingleScreenApp({
21 16
       navBarButtonColor: '#ffffff',
22 17
       statusBarTextColorScheme: 'light'
23 18
     }
24
-  },
25
-  drawer: {
26
-    left: {
27
-      screen: 'example.SideMenu'
28
-    }
29 19
   }
30
-  // tabsStyle: {
31
-  //   tabBarButtonColor: '#ffff00',
32
-  //   tabBarSelectedButtonColor: '#ff9900',
33
-  //   tabBarBackgroundColor: '#551A8B'
34
-  // },
35 20
 });