Skip to content

Commit

Permalink
[react-native] Upgrade to 0.62.2 (#8310)
Browse files Browse the repository at this point in the history
# Why

Let's have latest React Native in the upcoming SDK!

# How

See the story at https://www.notion.so/expo/React-Native-Upgrade-Diary-947bc0b506a942189fd47ff6e53bf95b.

# Test Plan

Expo Client runs, versioned SDK38 also runs (after a couple of post-version fixes outlined in the aforementioned doc).

`expo-cli` can't handle `client_log` events, but that's something we may want to figure out after merging this PR, I guess.
  • Loading branch information
sjchmiela committed May 25, 2020
1 parent 935641f commit a4cabf3
Show file tree
Hide file tree
Showing 2,692 changed files with 46,594 additions and 30,459 deletions.
2 changes: 1 addition & 1 deletion android/ReactAndroid/DevExperience.md
Expand Up @@ -8,7 +8,7 @@ Make sure you have the following installed:
- SDK build tools version 23
- Android Support Repository 17 (for Android Support Library)

Follow steps on https://github.com/facebook/react-native/blob/master/react-native-cli/CONTRIBUTING.md, but be sure to bump the version of react-native in package.json to some version > 0.9 (latest published npm version) or set up proxying properly for react-native
Follow steps on https://github.com/react-native-community/cli/blob/master/CONTRIBUTING.md, but be sure to bump the version of react-native in package.json to some version > 0.9 (latest published npm version) or set up proxying properly for react-native

- From the react-native-android repo:
- `./gradlew :ReactAndroid:installArchives`
Expand Down
65 changes: 50 additions & 15 deletions android/ReactAndroid/build.gradle
@@ -1,7 +1,9 @@
// Copyright (c) Facebook, Inc. and its affiliates.

// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

plugins {
id("com.android.library")
Expand Down Expand Up @@ -294,7 +296,8 @@ def getNdkBuildFullPath() {
}

def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) {
dependsOn(prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog)
dependsOn(prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog, extractAARHeaders, extractJNIFiles)

inputs.dir("$projectDir/../ReactCommon")
inputs.dir("src/main/jni")
inputs.dir("src/main/java/com/facebook/react/modules/blob")
Expand Down Expand Up @@ -342,6 +345,34 @@ def packageReactNdkLibsForBuck = tasks.register("packageReactNdkLibsForBuck", Co
into("src/main/jni/prebuilt/lib")
}

task extractAARHeaders {
doLast {
configurations.extractHeaders.files.each {
def file = it.absoluteFile
def packageName = file.name.tokenize('-')[0]
copy {
from zipTree(file)
into "$projectDir/src/main/jni/first-party/$packageName/headers"
include "**/*.h"
}
}
}
}

task extractJNIFiles {
doLast {
configurations.extractJNI.files.each {
def file = it.absoluteFile
def packageName = file.name.tokenize('-')[0]
copy {
from zipTree(file)
into "$projectDir/src/main/jni/first-party/$packageName/"
include "jni/**/*"
}
}
}
}

android {
compileSdkVersion 28

Expand Down Expand Up @@ -386,22 +417,30 @@ android {
}

tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(packageReactNdkLibs)
compileTask ->
compileTask.dependsOn(packageReactNdkLibs)
}

clean.dependsOn(cleanReactNdkLib)

lintOptions {
abortOnError(false)
}

packagingOptions {
exclude("META-INF/NOTICE")
exclude("META-INF/LICENSE")
}

configurations {
extractHeaders
extractJNI
}
}

dependencies {
api("com.facebook.infer.annotation:infer-annotation:0.11.2")
api("com.facebook.yoga:proguard-annotations:1.14.1")
api("javax.inject:javax.inject:1")
api("androidx.appcompat:appcompat:1.0.2")
api("com.facebook.fresco:fresco:${FRESCO_VERSION}")
Expand All @@ -411,6 +450,9 @@ dependencies {
api("com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}")
api("com.squareup.okhttp3:okhttp-urlconnection:${OKHTTP_VERSION}")
api("com.squareup.okio:okio:1.15.0")
api("com.facebook.fbjni:fbjni-java-only:0.0.3")
extractHeaders("com.facebook.fbjni:fbjni:0.0.2:headers")
extractJNI("com.facebook.fbjni:fbjni:0.0.2")

testImplementation("junit:junit:${JUNIT_VERSION}")
testImplementation("org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}")
Expand All @@ -421,16 +463,9 @@ dependencies {
testImplementation("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}")

androidTestImplementation(fileTree(dir: "src/main/third-party/java/buck-android-support/", include: ["*.jar"]))
//TODO: Refactor to extract versions of androidx dependencies
androidTestImplementation("androidx.test:runner:1.1.0")
androidTestImplementation("androidx.test:rules:1.1.0")
androidTestImplementation("androidx.test:runner:${ANDROIDX_TEST_VERSION}")
androidTestImplementation("androidx.test:rules:${ANDROIDX_TEST_VERSION}")
androidTestImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}")

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.yoga'
exclude group:'com.facebook.flipper', module: 'fbjni'
exclude group:'com.facebook.litho', module: 'litho-annotations'
}
}

apply(from: "release.gradle")
7 changes: 3 additions & 4 deletions android/ReactAndroid/gradle.properties
@@ -1,4 +1,4 @@
VERSION_NAME=0.61.4
VERSION_NAME=0.62.2
GROUP=com.facebook.react

POM_NAME=ReactNative
Expand All @@ -11,16 +11,15 @@ ROBOLECTRIC_VERSION=3.0
JUNIT_VERSION=4.12
FEST_ASSERT_CORE_VERSION=2.0M10

ANDROID_SUPPORT_TEST_VERSION=1.0.2
ANDROIDX_TEST_VERSION=1.1.0
FRESCO_VERSION=2.0.0
OKHTTP_VERSION=3.12.1
SO_LOADER_VERSION=0.6.0
SO_LOADER_VERSION=0.8.2

BOOST_VERSION=1_63_0
DOUBLE_CONVERSION_VERSION=1.1.6
FOLLY_VERSION=2018.10.22.00
GLOG_VERSION=0.3.5
FLIPPER_VERSION=0.23.4

android.useAndroidX=true
android.enableJetifier=true
Expand Down
7 changes: 5 additions & 2 deletions android/ReactAndroid/proguard-rules.pro
Expand Up @@ -25,22 +25,25 @@
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
-keep,allowobfuscation @interface com.facebook.jni.annotations.DoNotStrip

# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class *
-keep @com.facebook.common.internal.DoNotStrip class *
-keep @com.facebook.jni.annotations.DoNotStrip class *
-keepclassmembers class * {
@com.facebook.proguard.annotations.DoNotStrip *;
@com.facebook.common.internal.DoNotStrip *;
@com.facebook.jni.annotations.DoNotStrip *;
}

-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
void set*(***);
*** get*();
}

-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
-keep class * implements com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * implements com.facebook.react.bridge.NativeModule { *; }
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp <methods>; }
-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup <methods>; }
Expand Down
12 changes: 7 additions & 5 deletions android/ReactAndroid/release.gradle
@@ -1,7 +1,9 @@
// Copyright (c) Facebook, Inc. and its affiliates.

// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

apply(plugin: "maven")
apply(plugin: "signing")
Expand Down Expand Up @@ -102,7 +104,7 @@ afterEvaluate { project ->
archives(androidJavadocJar)
}

version = '37.0.0'
version = '38.0.0'
group = 'com.facebook.react'

signing {
Expand Down
@@ -0,0 +1,96 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.bridge;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import com.facebook.soloader.SoLoader;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import static com.facebook.react.bridge.Arguments.fromBundle;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

@RunWith(AndroidJUnit4.class)
public class ArgumentsTest {

@Before
public void setUp() {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
SoLoader.init(context, false);
}

@Test
public void testFromBundle() {
verifyBundle(createBundle());
}

/**
* When passing a bundle via {@link Intent} extras, it gets parceled and unparceled.
* Any array of bundles will return as an array of {@link Parcelable} instead. This test
* verifies that {@link Arguments#fromArray} handles this situation correctly.
*/
@Test
public void testFromMarshaledBundle() {
verifyBundle(marshalAndUnmarshalBundle(createBundle()));
}

private void verifyBundle(@NonNull Bundle bundle) {
WritableMap map = fromBundle(bundle);
assertNotNull(map);

assertEquals(ReadableType.Array, map.getType("children"));
ReadableArray children = map.getArray("children");
assertNotNull(children);
assertEquals(1, children.size());

assertEquals(ReadableType.Map, children.getType(0));
ReadableMap child = children.getMap(0);
assertNotNull(child);
assertEquals("exampleChild", child.getString("exampleChildKey"));
}

@NonNull
private Bundle marshalAndUnmarshalBundle(@NonNull Bundle bundle) {
Parcel parcel = null;
try {
parcel = Parcel.obtain();
bundle.writeToParcel(parcel, 0);

byte[] bytes = parcel.marshall();
parcel.unmarshall(bytes, 0, bytes.length);
parcel.setDataPosition(0);
return Bundle.CREATOR.createFromParcel(parcel);
} finally {
if (parcel != null) {
parcel.recycle();
}
}
}

@NonNull
private Bundle createBundle() {
Bundle bundle = new Bundle();
Bundle[] children = new Bundle[1];
children[0] = new Bundle();
children[0].putString("exampleChildKey", "exampleChild");
bundle.putSerializable("children", children);
return bundle;
}
}
@@ -1,9 +1,10 @@
/**
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.testing;

import com.facebook.react.bridge.BaseJavaModule;
Expand Down
@@ -1,9 +1,10 @@
/**
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.testing;

import static junit.framework.Assert.assertFalse;
Expand Down
@@ -1,9 +1,10 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.testing;

import com.facebook.react.bridge.JavaScriptContextHolder;
Expand Down
@@ -1,9 +1,10 @@
/**
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.testing;

import com.facebook.react.bridge.Arguments;
Expand Down
@@ -1,9 +1,10 @@
/**
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.testing;

import androidx.annotation.Nullable;
Expand Down
@@ -1,9 +1,10 @@
/**
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.react.testing;

import com.facebook.react.ReactPackage;
Expand Down

0 comments on commit a4cabf3

Please sign in to comment.