Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade react native #288

Merged
merged 2 commits into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion projects/Mallard/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ build/
.gradle
local.properties
*.iml
android/gradle.properties

# Visual Studio Code
#
Expand Down Expand Up @@ -71,3 +70,6 @@ html/crosswords.bundle/

#jest files
coverage

# CocoaPods
/ios/Pods/
20 changes: 20 additions & 0 deletions projects/Mallard/Mallard.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = package['name']
s.version = package['version']
s.summary = package['description']
s.license = package['license']

s.authors = package['author']
s.homepage = package['homepage']
s.platform = :ios, "9.0"

s.source = { :git => "https://github.com/guardian/editions.git", :tag => "v#{s.version}" }
s.source_files = "ios/**/*.{h,m}"

s.dependency 'React'
end
13 changes: 13 additions & 0 deletions projects/Mallard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

## Installing

rn update: run this to clear your cache
(https://medium.com/@abhisheknalwaya/how-to-clear-react-native-cache-c435c258834e)

```bash
watchman watch-del-all &&
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* &&
rm -rf node_modules/ &&
yarn cache clean &&
yarn install &&
yarn start -- --reset-cache
```

Start by installing our Node.js dependencies:

```bash
Expand Down
67 changes: 47 additions & 20 deletions projects/Mallard/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import com.android.build.OutputFile
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
Expand Down Expand Up @@ -74,11 +77,11 @@ import com.android.build.OutputFile
*/

project.ext.react = [
entryFile: "index.js"
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-sentry/sentry.gradle"

/**
* Set this to true to create two separate APKs instead of one:
Expand All @@ -96,6 +99,29 @@ def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def vcode = (int)(((new Date().getTime()/1000) - 1451606400) / 10)

/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'

/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);


android {
compileSdkVersion rootProject.ext.compileSdkVersion
sourceSets {
Expand Down Expand Up @@ -144,7 +170,7 @@ android {
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
Expand All @@ -153,31 +179,31 @@ android {
}
}
}
packagingOptions {
pickFirst '**/armeabi-v7a/libc++_shared.so'
pickFirst '**/x86/libc++_shared.so'
pickFirst '**/arm64-v8a/libc++_shared.so'
pickFirst '**/x86_64/libc++_shared.so'
pickFirst '**/x86/libjsc.so'
pickFirst '**/armeabi-v7a/libjsc.so'
}
}

dependencies {
implementation project(':react-native-iap')
implementation project(':react-native-device-info')
implementation project(':@react-native-community_netinfo')
implementation project(':react-native-sentry')
implementation project(':react-native-push-notification')
implementation project(':react-native-config')
implementation project(':react-native-keychain')
implementation project(':@react-native-community_masked-view')
implementation project(':react-native-webview')
implementation project(':react-native-zip-archive')
implementation project(':react-native-svg')
implementation project(':@react-native-community_async-storage')
implementation project(':rn-fetch-blob')
implementation project(':react-native-screens')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
// These should be auto linked. TODO: TEST THIS
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.firebase:firebase-messaging:18.0.0"
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}

// Run this once to be able to run the application with BUCK
Expand All @@ -187,4 +213,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
into 'libs'
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.gms.google-services'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
7 changes: 0 additions & 7 deletions projects/Mallard/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,3 @@
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,8 @@

import android.app.Application;

import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.dooboolab.RNIap.RNIapPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.reactnativecommunity.netinfo.NetInfoPackage;
import io.sentry.RNSentryPackage;
import com.dieam.reactnativepushnotification.ReactNativePushNotificationPackage;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.oblador.keychain.KeychainPackage;
import org.reactnative.maskedview.RNCMaskedViewPackage;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.rnziparchive.RNZipArchivePackage;
import com.horcrux.svg.SvgPackage;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.RNFetchBlob.RNFetchBlobPackage;
import com.swmansion.rnscreens.RNScreensPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
Expand All @@ -36,24 +22,25 @@ public boolean getUseDeveloperSupport() {

@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNIapPackage(),
new RNDeviceInfo(),
new NetInfoPackage(),
new RNSentryPackage(),
new ReactNativePushNotificationPackage(),
new ReactNativeConfigPackage(),
new KeychainPackage(),
new RNCMaskedViewPackage(),
new RNCWebViewPackage(),
new RNZipArchivePackage(),
new SvgPackage(),
new AsyncStoragePackage(),
new RNFetchBlobPackage(),
new RNScreensPackage(),
new RNGestureHandlerPackage()
);
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();

// packages.add(new MainReactPackage());
// packages.add(new RNDeviceInfo());
// packages.add(new NetInfoPackage());
// packages.add(new RNSentryPackage());
// packages.add(new ReactNativePushNotificationPackage());
// packages.add(new ReactNativeConfigPackage());
// packages.add(new KeychainPackage());
// packages.add(new RNCMaskedViewPackage());
// packages.add(new RNCWebViewPackage());
// packages.add(new RNZipArchivePackage());
// packages.add(new SvgPackage());
// packages.add(new AsyncStoragePackage());
// packages.add(new RNFetchBlobPackage());
// packages.add(new RNScreensPackage());
// packages.add(new RNGestureHandlerPackage());
return packages;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
</style>


Expand Down
10 changes: 7 additions & 3 deletions projects/Mallard/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath("com.android.tools.build:gradle:3.4.1")
classpath("com.google.gms:google-services:4.2.0")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -32,10 +32,14 @@ allprojects {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
}

configurations.all {
resolutionStrategy {
resolutionStrategy {
force 'com.google.android.gms:play-services-gcm:16.1.0'
}
}
Expand Down
5 changes: 5 additions & 0 deletions projects/Mallard/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
18 changes: 16 additions & 2 deletions projects/Mallard/android/gradlew
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +42,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
Loading