Skip to content

Commit 2c55049

Browse files
a7medevHeshamMegid
authored andcommitted
[MOB-12422] Upgrade Example App to React Native 0.71 (#982)
Upgrade the default example app's React Native version to latest (0.71).
1 parent 3ff1dab commit 2c55049

31 files changed

+3556
-3378
lines changed

examples/default/.detoxrc.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/** @type {Detox.DetoxConfig} */
2+
module.exports = {
3+
testRunner: {
4+
$0: 'jest',
5+
args: {
6+
config: 'e2e/config.json',
7+
_: ['e2e'],
8+
},
9+
},
10+
apps: {
11+
'ios.debug': {
12+
type: 'ios.app',
13+
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/InstabugExample.app',
14+
build:
15+
'xcodebuild -workspace ios/InstabugExample.xcworkspace -scheme InstabugExample -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
16+
},
17+
'ios.release': {
18+
type: 'ios.app',
19+
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/InstabugExample.app',
20+
build:
21+
'xcodebuild -workspace ios/InstabugExample.xcworkspace -scheme InstabugExample -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
22+
},
23+
'android.debug': {
24+
type: 'android.apk',
25+
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
26+
build:
27+
'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..',
28+
},
29+
'android.release': {
30+
type: 'android.apk',
31+
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
32+
build:
33+
'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && cd ..',
34+
},
35+
},
36+
devices: {
37+
simulator: {
38+
type: 'ios.simulator',
39+
device: {
40+
type: 'iPhone 13 Pro Max',
41+
},
42+
},
43+
emulator: {
44+
type: 'android.emulator',
45+
device: {
46+
avdName: 'Nexus_6P_API_27',
47+
},
48+
},
49+
},
50+
configurations: {
51+
'ios.sim.debug': {
52+
device: 'simulator',
53+
app: 'ios.debug',
54+
},
55+
'ios.sim.release': {
56+
device: 'simulator',
57+
app: 'ios.release',
58+
},
59+
'android.emu.debug': {
60+
device: 'emulator',
61+
app: 'android.debug',
62+
},
63+
'android.emu.release': {
64+
device: 'emulator',
65+
app: 'android.release',
66+
},
67+
},
68+
};

examples/default/.detoxrc.json

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

examples/default/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 73 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,56 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "com.facebook.react"
23

34
import com.android.build.OutputFile
45

56
/**
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: "../../node_modules/react-native/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. If none specified and
19-
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
20-
* // default. Can be overridden with ENTRY_FILE environment variable.
21-
* entryFile: "index.android.js",
22-
*
23-
* // https://reactnative.dev/docs/performance#enable-the-ram-format
24-
* bundleCommand: "ram-bundle",
25-
*
26-
* // whether to bundle JS and assets in debug mode
27-
* bundleInDebug: false,
28-
*
29-
* // whether to bundle JS and assets in release mode
30-
* bundleInRelease: true,
31-
*
32-
* // whether to bundle JS and assets in another build variant (if configured).
33-
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
34-
* // The configuration property can be in the following formats
35-
* // 'bundleIn${productFlavor}${buildType}'
36-
* // 'bundleIn${buildType}'
37-
* // bundleInFreeDebug: true,
38-
* // bundleInPaidRelease: true,
39-
* // bundleInBeta: true,
40-
*
41-
* // whether to disable dev mode in custom build variants (by default only disabled in release)
42-
* // for example: to disable dev mode in the staging build type (if configured)
43-
* devDisabledInStaging: true,
44-
* // The configuration property can be in the following formats
45-
* // 'devDisabledIn${productFlavor}${buildType}'
46-
* // 'devDisabledIn${buildType}'
47-
*
48-
* // the root of your project, i.e. where "package.json" lives
49-
* root: "../../",
50-
*
51-
* // where to put the JS bundle asset in debug mode
52-
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
53-
*
54-
* // where to put the JS bundle asset in release mode
55-
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
56-
*
57-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
58-
* // require('./image.png')), in debug mode
59-
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
60-
*
61-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
62-
* // require('./image.png')), in release mode
63-
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
64-
*
65-
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
66-
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
67-
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
68-
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
69-
* // for example, you might want to remove it from here.
70-
* inputExcludes: ["android/**", "ios/**"],
71-
*
72-
* // override which node gets called and with what additional arguments
73-
* nodeExecutableAndArgs: ["node"],
74-
*
75-
* // supply additional arguments to the packager
76-
* extraPackagerArgs: []
77-
* ]
7+
* This is the configuration block to customize your React Native Android app.
8+
* By default you don't need to apply any configuration, just uncomment the lines you need.
789
*/
79-
80-
project.ext.react = [
81-
enableHermes: false, // clean and rebuild if changing
82-
]
83-
84-
apply from: "../../node_modules/react-native/react.gradle"
10+
react {
11+
/* Folders */
12+
// The root of your project, i.e. where "package.json" lives. Default is '..'
13+
// root = file("../")
14+
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
15+
// reactNativeDir = file("../node_modules/react-native")
16+
// The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
17+
// codegenDir = file("../node_modules/react-native-codegen")
18+
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
19+
// cliFile = file("../node_modules/react-native/cli.js")
20+
21+
/* Variants */
22+
// The list of variants to that are debuggable. For those we're going to
23+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
24+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
25+
// debuggableVariants = ["liteDebug", "prodDebug"]
26+
27+
/* Bundling */
28+
// A list containing the node command and its flags. Default is just 'node'.
29+
// nodeExecutableAndArgs = ["node"]
30+
//
31+
// The command to run when bundling. By default is 'bundle'
32+
// bundleCommand = "ram-bundle"
33+
//
34+
// The path to the CLI configuration file. Default is empty.
35+
// bundleConfig = file(../rn-cli.config.js)
36+
//
37+
// The name of the generated asset file containing your JS bundle
38+
// bundleAssetName = "MyApplication.android.bundle"
39+
//
40+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
41+
// entryFile = file("../js/MyApplication.android.js")
42+
//
43+
// A list of extra flags to pass to the 'bundle' commands.
44+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
45+
// extraPackagerArgs = []
46+
47+
/* Hermes Commands */
48+
// The hermes compiler command to run. By default it is 'hermesc'
49+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
50+
//
51+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
52+
// hermesFlags = ["-O", "-output-source-map"]
53+
}
8554

8655
project.ext.vectoricons = [
8756
iconFontNames: ['Ionicons.ttf']
@@ -90,52 +59,47 @@ project.ext.vectoricons = [
9059
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
9160

9261
/**
93-
* Set this to true to create two separate APKs instead of one:
94-
* - An APK that only works on ARM devices
95-
* - An APK that only works on x86 devices
96-
* The advantage is the size of the APK is reduced by about 4MB.
97-
* Upload all the APKs to the Play Store and people will download
98-
* the correct one based on the CPU architecture of their device.
62+
* Set this to true to create four separate APKs instead of one,
63+
* one for each native architecture. This is useful if you don't
64+
* use App Bundles (https://developer.android.com/guide/app-bundle/)
65+
* and want to have separate APKs to upload to the Play Store.
9966
*/
10067
def enableSeparateBuildPerCPUArchitecture = false
10168

10269
/**
103-
* Run Proguard to shrink the Java bytecode in release builds.
70+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
10471
*/
10572
def enableProguardInReleaseBuilds = false
10673

10774
/**
108-
* The preferred build flavor of JavaScriptCore.
75+
* The preferred build flavor of JavaScriptCore (JSC)
10976
*
11077
* For example, to use the international variant, you can use:
11178
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
11279
*
11380
* The international variant includes ICU i18n library and necessary data
11481
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
115-
* give correct results when using with locales other than en-US. Note that
82+
* give correct results when using with locales other than en-US. Note that
11683
* this variant is about 6MiB larger per architecture than default.
11784
*/
11885
def jscFlavor = 'org.webkit:android-jsc:+'
11986

12087
/**
121-
* Whether to enable the Hermes VM.
122-
*
123-
* This should be set on project.ext.react and mirrored here. If it is not set
124-
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
125-
* and the benefits of using Hermes will therefore be sharply reduced.
126-
*/
127-
def enableHermes = project.ext.react.get("enableHermes", false);
128-
129-
/**
130-
* Architectures to build native code for in debug.
88+
* Private function to get the list of Native Architectures you want to build.
89+
* This reads the value from reactNativeArchitectures in your gradle.properties
90+
* file and works together with the --active-arch-only flag of react-native run-android.
13191
*/
132-
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
92+
def reactNativeArchitectures() {
93+
def value = project.getProperties().get("reactNativeArchitectures")
94+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
95+
}
13396

13497
android {
13598
ndkVersion rootProject.ext.ndkVersion
13699

137100
compileSdkVersion rootProject.ext.compileSdkVersion
138101

102+
namespace "com.instabug.react.example"
139103
defaultConfig {
140104
applicationId "com.instabug.react.example"
141105
minSdkVersion rootProject.ext.minSdkVersion
@@ -146,12 +110,13 @@ android {
146110
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
147111
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
148112
}
113+
149114
splits {
150115
abi {
151116
reset()
152117
enable enableSeparateBuildPerCPUArchitecture
153118
universalApk false // If true, also generate a universal APK
154-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
119+
include (*reactNativeArchitectures())
155120
}
156121
}
157122
signingConfigs {
@@ -165,18 +130,14 @@ android {
165130
buildTypes {
166131
debug {
167132
signingConfig signingConfigs.debug
168-
if (nativeArchitectures) {
169-
ndk {
170-
abiFilters nativeArchitectures.split(',')
171-
}
172-
}
173133
}
174134
release {
175135
// Caution! In production, you need to generate your own keystore file.
176136
// see https://reactnative.dev/docs/signed-apk-android.
177137
signingConfig signingConfigs.debug
178138
minifyEnabled enableProguardInReleaseBuilds
179139
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
140+
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
180141
}
181142
}
182143

@@ -198,29 +159,19 @@ android {
198159
}
199160

200161
dependencies {
201-
implementation fileTree(dir: "libs", include: ["*.jar"])
202-
//noinspection GradleDynamicVersion
203-
implementation "com.facebook.react:react-native:+" // From node_modules
204-
implementation "androidx.multidex:multidex:2.0.1"
205-
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
206-
207-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
208-
exclude group:'com.facebook.fbjni'
209-
}
162+
// The version of react-native is set by the React Native Gradle Plugin
163+
implementation("com.facebook.react:react-android")
164+
165+
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
210166

167+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
211168
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
212-
exclude group:'com.facebook.flipper'
213169
exclude group:'com.squareup.okhttp3', module:'okhttp'
214170
}
215171

216-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
217-
exclude group:'com.facebook.flipper'
218-
}
219-
220-
if (enableHermes) {
221-
def hermesPath = "../../node_modules/hermes-engine/android/";
222-
debugImplementation files(hermesPath + "hermes-debug.aar")
223-
releaseImplementation files(hermesPath + "hermes-release.aar")
172+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
173+
if (hermesEnabled.toBoolean()) {
174+
implementation("com.facebook.react:hermes-android")
224175
} else {
225176
implementation jscFlavor
226177
}
@@ -230,11 +181,4 @@ dependencies {
230181
androidTestImplementation 'junit:junit:4.12'
231182
}
232183

233-
// Run this once to be able to run the application with BUCK
234-
// puts all compile dependencies into folder libs for BUCK to use
235-
task copyDownloadableDepsToLibs(type: Copy) {
236-
from configurations.implementation
237-
into 'libs'
238-
}
239-
240184
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

examples/default/android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
android:usesCleartextTraffic="true"
99
tools:targetApi="28"
1010
tools:ignore="GoogleAppIndexingWarning">
11-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
11+
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
1212
</application>
1313
</manifest>

0 commit comments

Comments
 (0)