Skip to content

Commit 53a616b

Browse files
Upgrade example app to RN 0.73.4 (#299)
* chore: upgrade to RN 0.73.4 * chore: resolve post upgrade bugs * chore: use node 18 on pipelines * chore: use package.json scripts on pipelines
1 parent 0dc53c2 commit 53a616b

46 files changed

Lines changed: 5621 additions & 5953 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/validate.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
- uses: actions/checkout@v2
1111
- uses: actions/setup-node@v2
1212
with:
13-
node-version: "16.x"
13+
node-version: "18.x"
1414
cache: "yarn"
1515
- run: yarn
16-
- run: yarn eslint .
16+
- run: yarn validate:eslint
1717

1818
tsc:
1919
runs-on: ubuntu-latest
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/checkout@v2
2323
- uses: actions/setup-node@v2
2424
with:
25-
node-version: "16.x"
25+
node-version: "18.x"
2626
cache: "yarn"
2727
- run: yarn
28-
- run: yarn tsc
28+
- run: yarn validate:typescript

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,11 @@ buck-out/
4848
\.buckd/
4949
android/app/libs
5050
android/keystores/debug.keystore
51+
*.keystore
52+
!debug.keystore
53+
54+
# Temporary files created by Metro to check the health of the file watcher
55+
.metro-health-check*
56+
57+
# testing
58+
/coverage

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
presets: ['module:metro-react-native-babel-preset'],
2+
presets: ['module:@react-native/babel-preset'],
33
plugins: [
44
[
55
'module-resolver',

example/android/app/_BUCK

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

example/android/app/build.gradle

Lines changed: 9 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "org.jetbrains.kotlin.android"
3+
apply plugin: "com.facebook.react"
24

35
import com.android.build.OutputFile
46
import org.apache.tools.ant.taskdefs.condition.Os
@@ -78,13 +80,6 @@ import org.apache.tools.ant.taskdefs.condition.Os
7880
* ]
7981
*/
8082

81-
project.ext.react = [
82-
enableHermes: true, // clean and rebuild if changing
83-
entryFile: "index.tsx"
84-
]
85-
86-
apply from: "../../node_modules/react-native/react.gradle"
87-
8883
/**
8984
* Set this to true to create two separate APKs instead of one:
9085
* - An APK that only works on ARM devices
@@ -113,103 +108,18 @@ def enableProguardInReleaseBuilds = false
113108
*/
114109
def jscFlavor = 'org.webkit:android-jsc:+'
115110

116-
/**
117-
* Whether to enable the Hermes VM.
118-
*
119-
* This should be set on project.ext.react and that value will be read here. If it is not set
120-
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
121-
* and the benefits of using Hermes will therefore be sharply reduced.
122-
*/
123-
def enableHermes = project.ext.react.get("enableHermes", false);
124-
125-
/**
126-
* Architectures to build native code for.
127-
*/
128-
def reactNativeArchitectures() {
129-
def value = project.getProperties().get("reactNativeArchitectures")
130-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
131-
}
132-
133111
android {
134112
ndkVersion rootProject.ext.ndkVersion
113+
buildToolsVersion rootProject.ext.buildToolsVersion
114+
compileSdk rootProject.ext.compileSdkVersion
135115

136-
compileSdkVersion rootProject.ext.compileSdkVersion
137-
116+
namespace "com.geolocationexample"
138117
defaultConfig {
139118
applicationId "com.geolocationexample"
140119
minSdkVersion rootProject.ext.minSdkVersion
141120
targetSdkVersion rootProject.ext.targetSdkVersion
142121
versionCode 1
143122
versionName "1.0"
144-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
145-
146-
if (isNewArchitectureEnabled()) {
147-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
148-
externalNativeBuild {
149-
cmake {
150-
arguments "-DPROJECT_BUILD_DIR=$buildDir",
151-
"-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
152-
"-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
153-
"-DNODE_MODULES_DIR=$rootDir/../node_modules",
154-
"-DANDROID_STL=c++_shared"
155-
}
156-
}
157-
if (!enableSeparateBuildPerCPUArchitecture) {
158-
ndk {
159-
abiFilters (*reactNativeArchitectures())
160-
}
161-
}
162-
}
163-
}
164-
165-
if (isNewArchitectureEnabled()) {
166-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
167-
externalNativeBuild {
168-
cmake {
169-
path "$projectDir/src/main/jni/CMakeLists.txt"
170-
}
171-
}
172-
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
173-
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
174-
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
175-
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
176-
into("$buildDir/react-ndk/exported")
177-
}
178-
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
179-
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
180-
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
181-
into("$buildDir/react-ndk/exported")
182-
}
183-
afterEvaluate {
184-
// If you wish to add a custom TurboModule or component locally,
185-
// you should uncomment this line.
186-
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
187-
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
188-
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
189-
190-
// Due to a bug inside AGP, we have to explicitly set a dependency
191-
// between configureCMakeDebug* tasks and the preBuild tasks.
192-
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
193-
configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
194-
configureCMakeDebug.dependsOn(preDebugBuild)
195-
reactNativeArchitectures().each { architecture ->
196-
tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
197-
dependsOn("preDebugBuild")
198-
}
199-
tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
200-
dependsOn("preReleaseBuild")
201-
}
202-
}
203-
}
204-
}
205-
206-
splits {
207-
abi {
208-
reset()
209-
enable enableSeparateBuildPerCPUArchitecture
210-
universalApk false // If true, also generate a universal APK
211-
include (*reactNativeArchitectures())
212-
}
213123
}
214124
signingConfigs {
215125
debug {
@@ -231,83 +141,18 @@ android {
231141
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
232142
}
233143
}
234-
235-
// applicationVariants are e.g. debug, release
236-
applicationVariants.all { variant ->
237-
variant.outputs.each { output ->
238-
// For each separate APK per architecture, set a unique version code as described here:
239-
// https://developer.android.com/studio/build/configure-apk-splits.html
240-
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
241-
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
242-
def abi = output.getFilter(OutputFile.ABI)
243-
if (abi != null) { // null for the universal-debug, universal-release variants
244-
output.versionCodeOverride =
245-
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
246-
}
247-
248-
}
249-
}
250144
}
251145

252146
dependencies {
253-
implementation fileTree(dir: "libs", include: ["*.jar"])
254-
255-
//noinspection GradleDynamicVersion
256-
implementation "com.facebook.react:react-native:+" // From node_modules
147+
implementation("com.facebook.react:react-android")
148+
implementation("com.facebook.react:flipper-integration")
257149
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
258150

259-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
260-
exclude group:'com.facebook.fbjni'
261-
}
262-
263-
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
264-
exclude group:'com.facebook.flipper'
265-
exclude group:'com.squareup.okhttp3', module:'okhttp'
266-
}
267-
268-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
269-
exclude group:'com.facebook.flipper'
270-
}
271-
272-
if (enableHermes) {
273-
//noinspection GradleDynamicVersion
274-
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
275-
exclude group:'com.facebook.fbjni'
276-
}
151+
if (hermesEnabled.toBoolean()) {
152+
implementation("com.facebook.react:hermes-android")
277153
} else {
278154
implementation jscFlavor
279155
}
280156
}
281157

282-
if (isNewArchitectureEnabled()) {
283-
// If new architecture is enabled, we let you build RN from source
284-
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
285-
// This will be applied to all the imported transtitive dependency.
286-
configurations.all {
287-
resolutionStrategy.dependencySubstitution {
288-
substitute(module("com.facebook.react:react-native"))
289-
.using(project(":ReactAndroid"))
290-
.because("On New Architecture we're building React Native from source")
291-
substitute(module("com.facebook.react:hermes-engine"))
292-
.using(project(":ReactAndroid:hermes-engine"))
293-
.because("On New Architecture we're building Hermes from source")
294-
}
295-
}
296-
}
297-
298-
// Run this once to be able to run the application with BUCK
299-
// puts all compile dependencies into folder libs for BUCK to use
300-
task copyDownloadableDepsToLibs(type: Copy) {
301-
from configurations.implementation
302-
into 'libs'
303-
}
304-
305158
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
306-
307-
def isNewArchitectureEnabled() {
308-
// To opt-in for the New Architecture, you can either:
309-
// - Set `newArchEnabled` to true inside the `gradle.properties` file
310-
// - Invoke gradle with `-newArchEnabled=true`
311-
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
312-
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
313-
}

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@
99
<application
1010
android:usesCleartextTraffic="true"
1111
tools:targetApi="28"
12-
tools:ignore="GoogleAppIndexingWarning">
13-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
14-
</application>
12+
tools:ignore="GoogleAppIndexingWarning" />
1513
</manifest>

0 commit comments

Comments
 (0)