@nrwl/react-native 15.6.1 → 15.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/migrations.json +77 -0
  3. package/package.json +11 -11
  4. package/plugins/metro-resolver.js +16 -5
  5. package/plugins/metro-resolver.js.map +1 -1
  6. package/src/executors/build-android/build-android.impl.js +2 -3
  7. package/src/executors/build-android/build-android.impl.js.map +1 -1
  8. package/src/executors/build-android/build-android.impl.ts +2 -3
  9. package/src/executors/run-android/run-android.impl.js +2 -3
  10. package/src/executors/run-android/run-android.impl.js.map +1 -1
  11. package/src/executors/run-android/run-android.impl.ts +2 -2
  12. package/src/executors/run-ios/schema.json +8 -2
  13. package/src/generators/application/application.d.ts +1 -1
  14. package/src/generators/application/application.js +5 -6
  15. package/src/generators/application/application.js.map +1 -1
  16. package/src/generators/application/application.spec.ts +4 -4
  17. package/src/generators/application/files/app/.ruby-version +1 -0
  18. package/src/generators/application/files/app/Gemfile.template +6 -0
  19. package/src/generators/application/files/app/android/app/build.gradle.template +71 -217
  20. package/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template +2 -8
  21. package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +4 -2
  22. package/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template +3 -3
  23. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +13 -26
  24. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +19 -48
  25. package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +20 -0
  26. package/src/generators/application/files/app/android/build.gradle.template +13 -36
  27. package/src/generators/application/files/app/android/gradle.properties +4 -0
  28. package/src/generators/application/files/app/android/settings.gradle.template +2 -17
  29. package/src/generators/application/files/app/ios/Podfile.template +21 -5
  30. package/src/generators/application/files/app/ios/__className__/AppDelegate.h +2 -4
  31. package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +12 -109
  32. package/src/generators/application/files/app/ios/__className__/Info.plist.template +2 -2
  33. package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +4 -2
  34. package/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/contents.xcworkspacedata +10 -0
  35. package/src/generators/init/init.js +8 -7
  36. package/src/generators/init/init.js.map +1 -1
  37. package/src/generators/init/lib/gitignore-entries.d.ts +1 -1
  38. package/src/generators/init/lib/gitignore-entries.js +17 -10
  39. package/src/generators/init/lib/gitignore-entries.js.map +1 -1
  40. package/src/generators/upgrade-native/upgrade-native.d.ts +1 -1
  41. package/src/generators/upgrade-native/upgrade-native.js +7 -9
  42. package/src/generators/upgrade-native/upgrade-native.js.map +1 -1
  43. package/src/utils/chmod-android-gradle-files.d.ts +3 -0
  44. package/src/utils/chmod-android-gradle-files.js +24 -0
  45. package/src/utils/chmod-android-gradle-files.js.map +1 -0
  46. package/src/utils/versions.d.ts +14 -14
  47. package/src/utils/versions.js +14 -14
  48. package/src/utils/versions.js.map +1 -1
  49. package/src/generators/application/files/app/android/app/_BUCK.template +0 -55
  50. package/src/generators/application/files/app/android/app/build_defs.bzl +0 -19
  51. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/MainApplicationReactNativeHost.java.template +0 -116
  52. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/components/MainComponentsRegistry.java.template +0 -36
  53. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java.template +0 -48
  54. package/src/generators/application/files/app/android/app/src/main/jni/CMakeLists.txt.template +0 -6
  55. package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.cpp +0 -32
  56. package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.h +0 -16
  57. package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +0 -45
  58. package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h.template +0 -38
  59. package/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.cpp +0 -65
  60. package/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.h.template +0 -32
  61. package/src/generators/application/files/app/android/app/src/main/jni/OnLoad.cpp +0 -11
  62. package/src/generators/application/files/app/ios/__className__.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  63. package/src/utils/chmod-task.d.ts +0 -2
  64. package/src/utils/chmod-task.js +0 -18
  65. package/src/utils/chmod-task.js.map +0 -1
@@ -1,131 +1,89 @@
1
1
  apply plugin: "com.android.application"
2
2
  apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
3
+ apply plugin: "com.facebook.react"
3
4
 
4
5
  import com.android.build.OutputFile
5
- import org.apache.tools.ant.taskdefs.condition.Os
6
6
 
7
7
  /**
8
- * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
9
- * and bundleReleaseJsAndAssets).
10
- * These basically call `react-native bundle` with the correct arguments during the Android build
11
- * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
12
- * bundle directly from the development server. Below you can see all the possible configurations
13
- * and their defaults. If you decide to add a configuration block, make sure to add it before the
14
- * `apply from: "../../node_modules/react-native/react.gradle"` line.
15
- *
16
- * project.ext.react = [
17
- * // the name of the generated asset file containing your JS bundle
18
- * bundleAssetName: "index.android.bundle",
19
- *
20
- * // the entry file for bundle generation. If none specified and
21
- * // "index.android.js" exists, it will be used. Otherwise "index.js" is
22
- * // default. Can be overridden with ENTRY_FILE environment variable.
23
- * entryFile: "index.android.js",
24
- *
25
- * // https://reactnative.dev/docs/performance#enable-the-ram-format
26
- * bundleCommand: "ram-bundle",
27
- *
28
- * // whether to bundle JS and assets in debug mode
29
- * bundleInDebug: false,
30
- *
31
- * // whether to bundle JS and assets in release mode
32
- * bundleInRelease: true,
33
- *
34
- * // whether to bundle JS and assets in another build variant (if configured).
35
- * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
36
- * // The configuration property can be in the following formats
37
- * // 'bundleIn${productFlavor}${buildType}'
38
- * // 'bundleIn${buildType}'
39
- * // bundleInFreeDebug: true,
40
- * // bundleInPaidRelease: true,
41
- * // bundleInBeta: true,
42
- *
43
- * // whether to disable dev mode in custom build variants (by default only disabled in release)
44
- * // for example: to disable dev mode in the staging build type (if configured)
45
- * devDisabledInStaging: true,
46
- * // The configuration property can be in the following formats
47
- * // 'devDisabledIn${productFlavor}${buildType}'
48
- * // 'devDisabledIn${buildType}'
49
- *
50
- * // the root of your project, i.e. where "package.json" lives
51
- * root: "../../",
52
- *
53
- * // where to put the JS bundle asset in debug mode
54
- * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
55
- *
56
- * // where to put the JS bundle asset in release mode
57
- * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
58
- *
59
- * // where to put drawable resources / React Native assets, e.g. the ones you use via
60
- * // require('./image.png')), in debug mode
61
- * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
62
- *
63
- * // where to put drawable resources / React Native assets, e.g. the ones you use via
64
- * // require('./image.png')), in release mode
65
- * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
66
- *
67
- * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
68
- * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
69
- * // date; if you have any other folders that you want to ignore for performance reasons (gradle
70
- * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
71
- * // for example, you might want to remove it from here.
72
- * inputExcludes: ["android/**", "ios/**"],
73
- *
74
- * // override which node gets called and with what additional arguments
75
- * nodeExecutableAndArgs: ["node"],
76
- *
77
- * // supply additional arguments to the packager
78
- * extraPackagerArgs: []
79
- * ]
8
+ * This is the configuration block to customize your React Native Android app.
9
+ * By default you don't need to apply any configuration, just uncomment the lines you need.
80
10
  */
81
-
82
- project.ext.react = [
83
- // the entry file for bundle generation
84
- entryFile: "<%= entryFile %>",
85
- enableHermes: true, // clean and rebuild if changing
86
- ]
87
-
88
- apply from: "../../node_modules/react-native/react.gradle"
11
+ react {
12
+ /* Folders */
13
+ // The root of your project, i.e. where "package.json" lives. Default is '..'
14
+ // root = file("../")
15
+ // The folder where the react-native NPM package is. Default is ../node_modules/react-native
16
+ // reactNativeDir = file("../node_modules/react-native")
17
+ // The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
18
+ // codegenDir = file("../node_modules/react-native-codegen")
19
+ // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
20
+ // cliFile = file("../node_modules/react-native/cli.js")
21
+
22
+ /* Variants */
23
+ // The list of variants to that are debuggable. For those we're going to
24
+ // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
25
+ // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
26
+ // debuggableVariants = ["liteDebug", "prodDebug"]
27
+
28
+ /* Bundling */
29
+ // A list containing the node command and its flags. Default is just 'node'.
30
+ // nodeExecutableAndArgs = ["node"]
31
+ //
32
+ // The command to run when bundling. By default is 'bundle'
33
+ // bundleCommand = "ram-bundle"
34
+ //
35
+ // The path to the CLI configuration file. Default is empty.
36
+ // bundleConfig = file(../rn-cli.config.js)
37
+ //
38
+ // The name of the generated asset file containing your JS bundle
39
+ // bundleAssetName = "MyApplication.android.bundle"
40
+ //
41
+ // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
42
+ // entryFile = file("../js/MyApplication.android.js")
43
+ //
44
+ // A list of extra flags to pass to the 'bundle' commands.
45
+ // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
46
+ // extraPackagerArgs = []
47
+
48
+ /* Hermes Commands */
49
+ // The hermes compiler command to run. By default it is 'hermesc'
50
+ // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
51
+ //
52
+ // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
53
+ // hermesFlags = ["-O", "-output-source-map"]
54
+ entryFile = file("../../<%= entryFile %>")
55
+ }
89
56
 
90
57
  /**
91
- * Set this to true to create two separate APKs instead of one:
92
- * - An APK that only works on ARM devices
93
- * - An APK that only works on x86 devices
94
- * The advantage is the size of the APK is reduced by about 4MB.
95
- * Upload all the APKs to the Play Store and people will download
96
- * the correct one based on the CPU architecture of their device.
58
+ * Set this to true to create four separate APKs instead of one,
59
+ * one for each native architecture. This is useful if you don't
60
+ * use App Bundles (https://developer.android.com/guide/app-bundle/)
61
+ * and want to have separate APKs to upload to the Play Store.
97
62
  */
98
63
  def enableSeparateBuildPerCPUArchitecture = false
99
64
 
100
65
  /**
101
- * Run Proguard to shrink the Java bytecode in release builds.
66
+ * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
102
67
  */
103
68
  def enableProguardInReleaseBuilds = false
104
69
 
105
70
  /**
106
- * The preferred build flavor of JavaScriptCore.
71
+ * The preferred build flavor of JavaScriptCore (JSC)
107
72
  *
108
73
  * For example, to use the international variant, you can use:
109
74
  * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
110
75
  *
111
76
  * The international variant includes ICU i18n library and necessary data
112
77
  * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
113
- * give correct results when using with locales other than en-US. Note that
78
+ * give correct results when using with locales other than en-US. Note that
114
79
  * this variant is about 6MiB larger per architecture than default.
115
80
  */
116
81
  def jscFlavor = 'org.webkit:android-jsc:+'
117
82
 
118
83
  /**
119
- * Whether to enable the Hermes VM.
120
- *
121
- * This should be set on project.ext.react and that value will be read here. If it is not set
122
- * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
123
- * and the benefits of using Hermes will therefore be sharply reduced.
124
- */
125
- def enableHermes = project.ext.react.get("enableHermes", false);
126
-
127
- /**
128
- * Architectures to build native code for.
84
+ * Private function to get the list of Native Architectures you want to build.
85
+ * This reads the value from reactNativeArchitectures in your gradle.properties
86
+ * file and works together with the --active-arch-only flag of react-native run-android.
129
87
  */
130
88
  def reactNativeArchitectures() {
131
89
  def value = project.getProperties().get("reactNativeArchitectures")
@@ -137,77 +95,17 @@ android {
137
95
 
138
96
  compileSdkVersion rootProject.ext.compileSdkVersion
139
97
 
98
+ namespace "com.<%= lowerCaseName %>"
140
99
  defaultConfig {
141
100
  applicationId "com.<%= lowerCaseName %>"
142
101
  minSdkVersion rootProject.ext.minSdkVersion
143
102
  targetSdkVersion rootProject.ext.targetSdkVersion
144
103
  versionCode 1
145
104
  versionName "1.0"
146
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
147
105
  <% if (e2eTestRunner === 'detox') { %>
148
- testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
106
+ testBuildType System.getProperty('testBuildType', 'debug')
149
107
  testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
150
- missingDimensionStrategy 'detox', 'full'
151
108
  <% } %>
152
-
153
- if (isNewArchitectureEnabled()) {
154
- // We configure the CMake build only if you decide to opt-in for the New Architecture.
155
- externalNativeBuild {
156
- cmake {
157
- arguments "-DPROJECT_BUILD_DIR=$buildDir",
158
- "-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
159
- "-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
160
- "-DNODE_MODULES_DIR=$rootDir/../node_modules",
161
- "-DANDROID_STL=c++_shared"
162
- }
163
- }
164
- if (!enableSeparateBuildPerCPUArchitecture) {
165
- ndk {
166
- abiFilters (*reactNativeArchitectures())
167
- }
168
- }
169
- }
170
- }
171
-
172
- if (isNewArchitectureEnabled()) {
173
- // We configure the NDK build only if you decide to opt-in for the New Architecture.
174
- externalNativeBuild {
175
- cmake {
176
- path "$projectDir/src/main/jni/CMakeLists.txt"
177
- }
178
- }
179
- def reactAndroidProjectDir = project(':ReactAndroid').projectDir
180
- def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
181
- dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
182
- from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
183
- into("$buildDir/react-ndk/exported")
184
- }
185
- def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
186
- dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
187
- from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
188
- into("$buildDir/react-ndk/exported")
189
- }
190
- afterEvaluate {
191
- // If you wish to add a custom TurboModule or component locally,
192
- // you should uncomment this line.
193
- // preBuild.dependsOn("generateCodegenArtifactsFromSchema")
194
- preDebugBuild.dependsOn(packageReactNdkDebugLibs)
195
- preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
196
-
197
- // Due to a bug inside AGP, we have to explicitly set a dependency
198
- // between configureCMakeDebug* tasks and the preBuild tasks.
199
- // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
200
- configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
201
- configureCMakeDebug.dependsOn(preDebugBuild)
202
- reactNativeArchitectures().each { architecture ->
203
- tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
204
- dependsOn("preDebugBuild")
205
- }
206
- tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
207
- dependsOn("preReleaseBuild")
208
- }
209
- }
210
- }
211
109
  }
212
110
 
213
111
  splits {
@@ -237,7 +135,6 @@ android {
237
135
  minifyEnabled enableProguardInReleaseBuilds
238
136
  proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
239
137
  <% if (e2eTestRunner === 'detox') { %>
240
- // Detox-specific additions to pro-guard
241
138
  proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
242
139
  <% } %>
243
140
  }
@@ -261,70 +158,27 @@ android {
261
158
  }
262
159
 
263
160
  dependencies {
264
- implementation fileTree(dir: "libs", include: ["*.jar"])
265
-
266
- //noinspection GradleDynamicVersion
267
- implementation "com.facebook.react:react-native:+" // From node_modules
161
+ <% if (e2eTestRunner === 'detox') { %>
162
+ androidTestImplementation('com.wix:detox:+')
163
+ implementation 'androidx.appcompat:appcompat:1.1.0'
164
+ <% } %>
165
+ // The version of react-native is set by the React Native Gradle Plugin
166
+ implementation("com.facebook.react:react-android")
268
167
  implementation project(':react-native-config')
269
168
 
270
- implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
271
-
272
- debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
273
- exclude group:'com.facebook.fbjni'
274
- }
169
+ implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
275
170
 
171
+ debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
276
172
  debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
277
- exclude group:'com.facebook.flipper'
278
173
  exclude group:'com.squareup.okhttp3', module:'okhttp'
279
174
  }
280
175
 
281
- debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
282
- exclude group:'com.facebook.flipper'
283
- }
284
-
285
- if (enableHermes) {
286
- //noinspection GradleDynamicVersion
287
- implementation("com.facebook.react:hermes-engine:+") { // From node_modules
288
- exclude group:'com.facebook.fbjni'
289
- }
176
+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
177
+ if (hermesEnabled.toBoolean()) {
178
+ implementation("com.facebook.react:hermes-android")
290
179
  } else {
291
180
  implementation jscFlavor
292
181
  }
293
-
294
- <% if (e2eTestRunner === 'detox') { %>
295
- androidTestImplementation(project(path: ":detox"))
296
- <% } %>
297
- }
298
-
299
- if (isNewArchitectureEnabled()) {
300
- // If new architecture is enabled, we let you build RN from source
301
- // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
302
- // This will be applied to all the imported transtitive dependency.
303
- configurations.all {
304
- resolutionStrategy.dependencySubstitution {
305
- substitute(module("com.facebook.react:react-native"))
306
- .using(project(":ReactAndroid"))
307
- .because("On New Architecture we're building React Native from source")
308
- substitute(module("com.facebook.react:hermes-engine"))
309
- .using(project(":ReactAndroid:hermes-engine"))
310
- .because("On New Architecture we're building Hermes from source")
311
- }
312
- }
313
- }
314
-
315
- // Run this once to be able to run the application with BUCK
316
- // puts all compile dependencies into folder libs for BUCK to use
317
- task copyDownloadableDepsToLibs(type: Copy) {
318
- from configurations.implementation
319
- into 'libs'
320
182
  }
321
183
 
322
184
  apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
323
-
324
- def isNewArchitectureEnabled() {
325
- // To opt-in for the New Architecture, you can either:
326
- // - Set `newArchEnabled` to true inside the `gradle.properties` file
327
- // - Invoke gradle with `-newArchEnabled=true`
328
- // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
329
- return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
330
- }
@@ -15,21 +15,15 @@ import androidx.test.rule.ActivityTestRule;
15
15
  @RunWith(AndroidJUnit4.class)
16
16
  @LargeTest
17
17
  public class DetoxTest {
18
- // Replace 'MainActivity' with the value of android:name entry in
19
- // <activity> in AndroidManifest.xml
20
- @Rule
18
+ @Rule // (2)
21
19
  public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
22
20
 
23
21
  @Test
24
22
  public void runDetoxTests() {
25
- // This is optional - in case you've decided to integrate TestButler
26
- // See https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#8-test-butler-support-optional
27
- // TestButlerProbe.assertReadyIfInstalled();
28
-
29
23
  DetoxConfig detoxConfig = new DetoxConfig();
30
24
  detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
31
25
  detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
32
- detoxConfig.rnContextLoadTimeoutSec = (com.<%= lowerCaseName %>.BuildConfig.DEBUG ? 180 : 60);
26
+ detoxConfig.rnContextLoadTimeoutSec = (BuildConfig.DEBUG ? 180 : 60);
33
27
 
34
28
  Detox.runTests(mActivityRule, detoxConfig);
35
29
  }
@@ -17,7 +17,6 @@ import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17
17
  import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18
18
  import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19
19
  import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20
- import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21
20
  import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22
21
  import com.facebook.react.ReactInstanceEventListener;
23
22
  import com.facebook.react.ReactInstanceManager;
@@ -25,13 +24,16 @@ import com.facebook.react.bridge.ReactContext;
25
24
  import com.facebook.react.modules.network.NetworkingModule;
26
25
  import okhttp3.OkHttpClient;
27
26
 
27
+ /**
28
+ * Class responsible of loading Flipper inside your React Native application. This is the debug
29
+ * flavor of it. Here you can add your own plugins and customize the Flipper setup.
30
+ */
28
31
  public class ReactNativeFlipper {
29
32
  public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
30
33
  if (FlipperUtils.shouldEnableFlipper(context)) {
31
34
  final FlipperClient client = AndroidFlipperClient.getInstance(context);
32
35
 
33
36
  client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
34
- client.addPlugin(new ReactFlipperPlugin());
35
37
  client.addPlugin(new DatabasesFlipperPlugin(context));
36
38
  client.addPlugin(new SharedPreferencesFlipperPlugin(context));
37
39
  client.addPlugin(CrashReporterPlugin.getInstance());
@@ -1,5 +1,4 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.<%= lowerCaseName %>">
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
2
 
4
3
  <uses-permission android:name="android.permission.INTERNET" />
5
4
 
@@ -9,7 +8,8 @@
9
8
  android:icon="@mipmap/ic_launcher"
10
9
  android:roundIcon="@mipmap/ic_launcher_round"
11
10
  android:allowBackup="false"
12
- android:theme="@style/AppTheme">
11
+ android:theme="@style/AppTheme"
12
+ android:networkSecurityConfig="@xml/network_security_config">
13
13
  <activity
14
14
  android:name=".MainActivity"
15
15
  android:label="@string/app_name"
@@ -2,7 +2,8 @@ package com.<%= lowerCaseName %>;
2
2
 
3
3
  import com.facebook.react.ReactActivity;
4
4
  import com.facebook.react.ReactActivityDelegate;
5
- import com.facebook.react.ReactRootView;
5
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
6
+ import com.facebook.react.defaults.DefaultReactActivityDelegate;
6
7
 
7
8
  public class MainActivity extends ReactActivity {
8
9
 
@@ -16,33 +17,19 @@ public class MainActivity extends ReactActivity {
16
17
  }
17
18
 
18
19
  /**
19
- * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
20
- * you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
21
- * (Paper).
20
+ * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
21
+ * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
22
+ * (aka React 18) with two boolean flags.
22
23
  */
23
24
  @Override
24
25
  protected ReactActivityDelegate createReactActivityDelegate() {
25
- return new MainActivityDelegate(this, getMainComponentName());
26
- }
27
-
28
- public static class MainActivityDelegate extends ReactActivityDelegate {
29
- public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
30
- super(activity, mainComponentName);
31
- }
32
-
33
- @Override
34
- protected ReactRootView createRootView() {
35
- ReactRootView reactRootView = new ReactRootView(getContext());
36
- // If you opted-in for the New Architecture, we enable the Fabric Renderer.
37
- reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
38
- return reactRootView;
39
- }
40
-
41
- @Override
42
- protected boolean isConcurrentRootEnabled() {
43
- // If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
44
- // More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
45
- return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
46
- }
26
+ return new DefaultReactActivityDelegate(
27
+ this,
28
+ getMainComponentName(),
29
+ // If you opted-in for the New Architecture, we enable the Fabric Renderer.
30
+ DefaultNewArchitectureEntryPoint.getFabricEnabled(), // fabricEnabled
31
+ // If you opted-in for the New Architecture, we enable Concurrent React (i.e. React 18).
32
+ DefaultNewArchitectureEntryPoint.getConcurrentReactEnabled() // concurrentRootEnabled
33
+ );
47
34
  }
48
35
  }
@@ -1,23 +1,20 @@
1
1
  package com.<%= lowerCaseName %>;
2
2
 
3
3
  import android.app.Application;
4
- import android.content.Context;
5
4
  import com.facebook.react.PackageList;
6
5
  import com.facebook.react.ReactApplication;
7
- import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
8
- import com.facebook.react.ReactInstanceManager;
9
6
  import com.facebook.react.ReactNativeHost;
10
7
  import com.facebook.react.ReactPackage;
11
- import com.facebook.react.config.ReactFeatureFlags;
8
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
9
+ import com.facebook.react.defaults.DefaultReactNativeHost;
12
10
  import com.facebook.soloader.SoLoader;
13
- import com.<%= lowerCaseName %>.newarchitecture.MainApplicationReactNativeHost;
14
- import java.lang.reflect.InvocationTargetException;
15
11
  import java.util.List;
12
+ import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
16
13
 
17
14
  public class MainApplication extends Application implements ReactApplication {
18
15
 
19
16
  private final ReactNativeHost mReactNativeHost =
20
- new ReactNativeHost(this) {
17
+ new DefaultReactNativeHost(this) {
21
18
  @Override
22
19
  public boolean getUseDeveloperSupport() {
23
20
  return BuildConfig.DEBUG;
@@ -36,57 +33,31 @@ public class MainApplication extends Application implements ReactApplication {
36
33
  protected String getJSMainModuleName() {
37
34
  return "<%= entryFile %>";
38
35
  }
39
- };
40
36
 
41
- private final ReactNativeHost mNewArchitectureNativeHost =
42
- new MainApplicationReactNativeHost(this);
37
+ @Override
38
+ protected boolean isNewArchEnabled() {
39
+ return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
40
+ }
41
+
42
+ @Override
43
+ protected Boolean isHermesEnabled() {
44
+ return BuildConfig.IS_HERMES_ENABLED;
45
+ }
46
+ };
43
47
 
44
48
  @Override
45
49
  public ReactNativeHost getReactNativeHost() {
46
- if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
47
- return mNewArchitectureNativeHost;
48
- } else {
49
- return mReactNativeHost;
50
- }
50
+ return mReactNativeHost;
51
51
  }
52
52
 
53
53
  @Override
54
54
  public void onCreate() {
55
55
  super.onCreate();
56
- // If you opted-in for the New Architecture, we enable the TurboModule system
57
- ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
58
56
  SoLoader.init(this, /* native exopackage */ false);
59
- initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
60
- }
61
-
62
- /**
63
- * Loads Flipper in React Native templates. Call this in the onCreate method with something like
64
- * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
65
- *
66
- * @param context
67
- * @param reactInstanceManager
68
- */
69
- private static void initializeFlipper(
70
- Context context, ReactInstanceManager reactInstanceManager) {
71
- if (BuildConfig.DEBUG) {
72
- try {
73
- /*
74
- We use reflection here to pick up the class that initializes Flipper,
75
- since Flipper library is not available in release mode
76
- */
77
- Class<?> aClass = Class.forName("com.<%= lowerCaseName %>.ReactNativeFlipper");
78
- aClass
79
- .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
80
- .invoke(null, context, reactInstanceManager);
81
- } catch (ClassNotFoundException e) {
82
- e.printStackTrace();
83
- } catch (NoSuchMethodException e) {
84
- e.printStackTrace();
85
- } catch (IllegalAccessException e) {
86
- e.printStackTrace();
87
- } catch (InvocationTargetException e) {
88
- e.printStackTrace();
89
- }
57
+ if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
58
+ // If you opted-in for the New Architecture, we load the native entry point for this app.
59
+ DefaultNewArchitectureEntryPoint.load();
90
60
  }
61
+ ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
91
62
  }
92
63
  }
@@ -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.<%= lowerCaseName %>;
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
+ }