Skip to content

Commit 4541821

Browse files
committed
[chore] Upgrade example app to Expo 49 / RN 72
1 parent 8a1abc5 commit 4541821

File tree

27 files changed

+1549
-2658
lines changed

27 files changed

+1549
-2658
lines changed

example/.buckconfig

Lines changed: 0 additions & 6 deletions
This file was deleted.

example/__tests__/App.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

example/android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 0 additions & 2 deletions
This file was deleted.

example/android/app/BUCK

Lines changed: 0 additions & 55 deletions
This file was deleted.

example/android/app/build.gradle

Lines changed: 11 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
apply plugin: "com.android.application"
22
apply plugin: "com.facebook.react"
33

4-
import com.android.build.OutputFile
5-
64
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
7-
def expoDebuggableVariants = ['debug']
8-
// Override `debuggableVariants` for expo-updates debugging
9-
if (System.getenv('EX_UPDATES_NATIVE_DEBUG') == "1") {
10-
react {
11-
expoDebuggableVariants = []
12-
}
13-
}
14-
155

166
/**
177
* This is the configuration block to customize your React Native Android app.
@@ -21,17 +11,20 @@ react {
2111
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim())
2212
reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
2313
hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc"
24-
debuggableVariants = expoDebuggableVariants
14+
codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
15+
16+
// Use Expo CLI to bundle the app, this ensures the Metro config
17+
// works correctly with Expo projects.
18+
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
19+
bundleCommand = "export:embed"
2520

2621
/* Folders */
2722
// The root of your project, i.e. where "package.json" lives. Default is '..'
2823
// root = file("../")
2924
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
3025
// reactNativeDir = file("../node_modules/react-native")
31-
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
32-
// codegenDir = file("../node_modules/react-native-codegen")
33-
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
34-
// cliFile = file("../node_modules/react-native/cli.js")
26+
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
27+
// codegenDir = file("../node_modules/@react-native/codegen")
3528

3629
/* Variants */
3730
// The list of variants to that are debuggable. For those we're going to
@@ -42,9 +35,7 @@ react {
4235
/* Bundling */
4336
// A list containing the node command and its flags. Default is just 'node'.
4437
// nodeExecutableAndArgs = ["node"]
45-
//
46-
// The command to run when bundling. By default is 'bundle'
47-
// bundleCommand = "ram-bundle"
38+
4839
//
4940
// The path to the CLI configuration file. Default is empty.
5041
// bundleConfig = file(../rn-cli.config.js)
@@ -67,19 +58,6 @@ react {
6758
// hermesFlags = ["-O", "-output-source-map"]
6859
}
6960

70-
// Override `hermesEnabled` by `expo.jsEngine`
71-
ext {
72-
hermesEnabled = (findProperty('expo.jsEngine') ?: "hermes") == "hermes"
73-
}
74-
75-
/**
76-
* Set this to true to create four separate APKs instead of one,
77-
* one for each native architecture. This is useful if you don't
78-
* use App Bundles (https://developer.android.com/guide/app-bundle/)
79-
* and want to have separate APKs to upload to the Play Store.
80-
*/
81-
def enableSeparateBuildPerCPUArchitecture = false
82-
8361
/**
8462
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
8563
*/
@@ -98,16 +76,6 @@ def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInRelea
9876
*/
9977
def jscFlavor = 'org.webkit:android-jsc:+'
10078

101-
/**
102-
* Private function to get the list of Native Architectures you want to build.
103-
* This reads the value from reactNativeArchitectures in your gradle.properties
104-
* file and works together with the --active-arch-only flag of react-native run-android.
105-
*/
106-
def reactNativeArchitectures() {
107-
def value = project.getProperties().get("reactNativeArchitectures")
108-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
109-
}
110-
11179
android {
11280
ndkVersion rootProject.ext.ndkVersion
11381

@@ -119,16 +87,9 @@ android {
11987
minSdkVersion rootProject.ext.minSdkVersion
12088
targetSdkVersion rootProject.ext.targetSdkVersion
12189
versionCode 1
122-
versionName "1.0"
123-
}
90+
versionName "1.0.0"
12491

125-
splits {
126-
abi {
127-
reset()
128-
enable enableSeparateBuildPerCPUArchitecture
129-
universalApk false // If true, also generate a universal APK
130-
include (*reactNativeArchitectures())
131-
}
92+
buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString())
13293
}
13394
signingConfigs {
13495
debug {
@@ -151,22 +112,6 @@ android {
151112
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
152113
}
153114
}
154-
155-
// applicationVariants are e.g. debug, release
156-
applicationVariants.all { variant ->
157-
variant.outputs.each { output ->
158-
// For each separate APK per architecture, set a unique version code as described here:
159-
// https://developer.android.com/studio/build/configure-apk-splits.html
160-
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
161-
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
162-
def abi = output.getFilter(OutputFile.ABI)
163-
if (abi != null) { // null for the universal-debug, universal-release variants
164-
output.versionCodeOverride =
165-
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
166-
}
167-
168-
}
169-
}
170115
}
171116

172117
// Apply static values from `gradle.properties` to the `android.packagingOptions`
@@ -218,8 +163,6 @@ dependencies {
218163
}
219164
}
220165

221-
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
222-
223166
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
224167
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
225168
exclude group:'com.squareup.okhttp3', module:'okhttp'

example/android/app/build_defs.bzl

Lines changed: 0 additions & 19 deletions
This file was deleted.

example/android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
55

6-
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
6+
<application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" tools:replace="android:usesCleartextTraffic" />
77
</manifest>

example/android/app/src/debug/java/nl/ijzerenhein/navigationsharedelementexample/ReactNativeFlipper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public void onReactContextInitialized(ReactContext reactContext) {
6161
reactContext.runOnNativeModulesQueueThread(
6262
new Runnable() {
6363
@Override
64-
public void run() { client.addPlugin(new FrescoFlipperPlugin());
64+
public void run() {
65+
client.addPlugin(new FrescoFlipperPlugin());
6566
}
6667
});
6768
}

example/android/app/src/main/AndroidManifest.xml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.sharedelementexample">
3-
4-
<uses-permission android:name="android.permission.INTERNET" />
5-
<!-- OPTIONAL PERMISSIONS, REMOVE WHATEVER YOU DO NOT NEED -->
6-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
7-
<uses-permission android:name="android.permission.VIBRATE" />
8-
<!-- These require runtime permissions on M -->
9-
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
10-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
11-
<!-- END OPTIONAL PERMISSIONS -->
12-
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<uses-permission android:name="android.permission.INTERNET"/>
3+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
4+
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5+
<uses-permission android:name="android.permission.VIBRATE"/>
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
137
<queries>
14-
<!-- Support checking for http(s) links via the Linking API -->
158
<intent>
16-
<action android:name="android.intent.action.VIEW" />
17-
<category android:name="android.intent.category.BROWSABLE" />
18-
<data android:scheme="https" />
9+
<action android:name="android.intent.action.VIEW"/>
10+
<category android:name="android.intent.category.BROWSABLE"/>
11+
<data android:scheme="https"/>
1912
</intent>
2013
</queries>
21-
2214
<application
2315
android:name=".MainApplication"
2416
android:label="@string/app_name"
2517
android:icon="@mipmap/ic_launcher"
2618
android:roundIcon="@mipmap/ic_launcher_round"
2719
android:allowBackup="false"
28-
android:theme="@style/AppTheme"
29-
android:usesCleartextTraffic="true">
30-
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="YOUR-APP-URL-HERE" />
31-
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION"
32-
android:value="YOUR-APP-SDK-VERSION-HERE" />
20+
android:theme="@style/AppTheme">
21+
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
22+
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="49.0.0"/>
23+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
24+
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
3325
<activity
3426
android:name=".MainActivity"
3527
android:label="@string/app_name"
3628
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
3729
android:launchMode="singleTask" android:windowSoftInputMode="adjustResize"
3830
android:theme="@style/Theme.App.SplashScreen" android:exported="true"
31+
android:screenOrientation="portrait"
3932
>
33+
<intent-filter>
34+
<action android:name="android.intent.action.MAIN"/>
35+
<category android:name="android.intent.category.LAUNCHER"/>
36+
</intent-filter>
4037
<intent-filter>
41-
<action android:name="android.intent.action.MAIN" />
42-
<category android:name="android.intent.category.LAUNCHER" />
38+
<action android:name="android.intent.action.VIEW"/>
39+
<category android:name="android.intent.category.DEFAULT"/>
40+
<category android:name="android.intent.category.BROWSABLE"/>
41+
<data android:scheme="com.anonymous.Expo49TS"/>
4342
</intent-filter>
4443
</activity>
4544
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity"

example/android/app/src/main/java/com/sharedelementexample/MainActivity.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ protected ReactActivityDelegate createReactActivityDelegate() {
4040
this,
4141
getMainComponentName(),
4242
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
43-
DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
44-
// If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
45-
DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
46-
));
43+
DefaultNewArchitectureEntryPoint.getFabricEnabled()));
4744
}
4845

4946
/**

example/android/app/src/main/java/com/sharedelementexample/MainApplication.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.facebook.react.ReactApplication;
99
import com.facebook.react.ReactNativeHost;
1010
import com.facebook.react.ReactPackage;
11+
import com.facebook.react.config.ReactFeatureFlags;
1112
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
1213
import com.facebook.react.defaults.DefaultReactNativeHost;
1314
import com.facebook.soloader.SoLoader;
@@ -60,6 +61,9 @@ public ReactNativeHost getReactNativeHost() {
6061
public void onCreate() {
6162
super.onCreate();
6263
SoLoader.init(this, /* native exopackage */ false);
64+
if (!BuildConfig.REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS) {
65+
ReactFeatureFlags.unstable_useRuntimeSchedulerAlways = false;
66+
}
6367
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
6468
// If you opted-in for the New Architecture, we load the native entry point for this app.
6569
DefaultNewArchitectureEntryPoint.load();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5+
* directory of this source tree.
6+
*/
7+
package com.sharedelementexample;
8+
9+
import android.content.Context;
10+
import com.facebook.react.ReactInstanceManager;
11+
12+
/**
13+
* Class responsible of loading Flipper inside your React Native application. This is the release
14+
* flavor of it so it's empty as we don't want to load Flipper.
15+
*/
16+
public class ReactNativeFlipper {
17+
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
18+
// Do nothing as we don't want to initialize Flipper on Release.
19+
}
20+
}

example/android/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ buildscript {
66
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '21')
77
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '33')
88
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '33')
9-
if (findProperty('android.kotlinVersion')) {
10-
kotlinVersion = findProperty('android.kotlinVersion')
11-
}
9+
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.8.10'
1210
frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
1311

1412
// <react-native-fast-image>
@@ -30,7 +28,7 @@ buildscript {
3028
mavenCentral()
3129
}
3230
dependencies {
33-
classpath('com.android.tools.build:gradle:7.4.1')
31+
classpath('com.android.tools.build:gradle:7.4.2')
3432
classpath('com.facebook.react:react-native-gradle-plugin')
3533
}
3634
}

0 commit comments

Comments
 (0)