Skip to content

Commit a209b73

Browse files
committed
chore: upgrade rn & fix issues (fabric example)
1 parent 2e37b48 commit a209b73

36 files changed

+3183
-2813
lines changed

.gitignore

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,6 @@ npm-debug.log
4747
yarn-debug.log
4848
yarn-error.log
4949

50-
# BUCK
51-
buck-out/
52-
\.buckd/
53-
android/app/libs
54-
android/keystores/debug.keystore
55-
5650
# Expo
5751
.expo/*
5852

@@ -76,4 +70,6 @@ lefthook.yml
7670
.cxx
7771

7872
#Testing
73+
/coverage
7974
example/coverage
75+
fabricexample/coverage

android/src/fabric/java/com/reactnativepagerview/PagerViewViewManager.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ class PagerViewViewManager : ViewGroupManager<NestedScrollableHost>(), RNCViewPa
174174
val canScroll = childCount != null && childCount > 0 && selectedPage >= 0 && selectedPage < childCount
175175
if (canScroll) {
176176
PagerViewViewManagerImpl.setCurrentItem(view, selectedPage, scrollWithAnimation)
177-
val reactContext = view.context as ReactContext
178-
UIManagerHelper.getEventDispatcherForReactTag(reactContext, view.id)?.dispatchEvent(
179-
PageSelectedEvent(view.id, selectedPage)
180-
)
181177
}
182178
}
183179

android/src/paper/java/com/reactnativepagerview/PagerViewViewManager.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ class PagerViewViewManager : ViewGroupManager<NestedScrollableHost>() {
146146
if (canScroll) {
147147
val scrollWithAnimation = commandId == COMMAND_SET_PAGE
148148
PagerViewViewManagerImpl.setCurrentItem(view, pageIndex, scrollWithAnimation)
149-
eventDispatcher.dispatchEvent(PageSelectedEvent(root.id, pageIndex))
150149
}
151150
}
152151
COMMAND_SET_SCROLL_ENABLED -> {

fabricexample/Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source 'https://rubygems.org'
22

33
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4-
ruby '2.7.5'
4+
ruby ">= 2.6.10"
55

6-
gem 'cocoapods', '~> 1.11', '>= 1.11.2'
6+
gem 'cocoapods', '~> 1.12'
Lines changed: 66 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,87 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "com.facebook.react"
23

34
import com.android.build.OutputFile
4-
import org.apache.tools.ant.taskdefs.condition.Os
55

66
/**
7-
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
8-
* and bundleReleaseJsAndAssets).
9-
* These basically call `react-native bundle` with the correct arguments during the Android build
10-
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
11-
* bundle directly from the development server. Below you can see all the possible configurations
12-
* and their defaults. If you decide to add a configuration block, make sure to add it before the
13-
* `apply from: "../../node_modules/react-native/react.gradle"` line.
14-
*
15-
* project.ext.react = [
16-
* // the name of the generated asset file containing your JS bundle
17-
* bundleAssetName: "index.android.bundle",
18-
*
19-
* // the entry file for bundle generation. If none specified and
20-
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
21-
* // default. Can be overridden with ENTRY_FILE environment variable.
22-
* entryFile: "index.android.js",
23-
*
24-
* // https://reactnative.dev/docs/performance#enable-the-ram-format
25-
* bundleCommand: "ram-bundle",
26-
*
27-
* // whether to bundle JS and assets in debug mode
28-
* bundleInDebug: false,
29-
*
30-
* // whether to bundle JS and assets in release mode
31-
* bundleInRelease: true,
32-
*
33-
* // whether to bundle JS and assets in another build variant (if configured).
34-
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
35-
* // The configuration property can be in the following formats
36-
* // 'bundleIn${productFlavor}${buildType}'
37-
* // 'bundleIn${buildType}'
38-
* // bundleInFreeDebug: true,
39-
* // bundleInPaidRelease: true,
40-
* // bundleInBeta: true,
41-
*
42-
* // whether to disable dev mode in custom build variants (by default only disabled in release)
43-
* // for example: to disable dev mode in the staging build type (if configured)
44-
* devDisabledInStaging: true,
45-
* // The configuration property can be in the following formats
46-
* // 'devDisabledIn${productFlavor}${buildType}'
47-
* // 'devDisabledIn${buildType}'
48-
*
49-
* // the root of your project, i.e. where "package.json" lives
50-
* root: "../../",
51-
*
52-
* // where to put the JS bundle asset in debug mode
53-
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
54-
*
55-
* // where to put the JS bundle asset in release mode
56-
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
57-
*
58-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
59-
* // require('./image.png')), in debug mode
60-
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
61-
*
62-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
63-
* // require('./image.png')), in release mode
64-
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
65-
*
66-
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
67-
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
68-
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
69-
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
70-
* // for example, you might want to remove it from here.
71-
* inputExcludes: ["android/**", "ios/**"],
72-
*
73-
* // override which node gets called and with what additional arguments
74-
* nodeExecutableAndArgs: ["node"],
75-
*
76-
* // supply additional arguments to the packager
77-
* extraPackagerArgs: []
78-
* ]
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.
799
*/
80-
81-
project.ext.react = [
82-
enableHermes: true, // clean and rebuild if changing
83-
]
84-
85-
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+
}
8654

8755
/**
88-
* Set this to true to create two separate APKs instead of one:
89-
* - An APK that only works on ARM devices
90-
* - An APK that only works on x86 devices
91-
* The advantage is the size of the APK is reduced by about 4MB.
92-
* Upload all the APKs to the Play Store and people will download
93-
* the correct one based on the CPU architecture of their device.
56+
* Set this to true to create four separate APKs instead of one,
57+
* one for each native architecture. This is useful if you don't
58+
* use App Bundles (https://developer.android.com/guide/app-bundle/)
59+
* and want to have separate APKs to upload to the Play Store.
9460
*/
9561
def enableSeparateBuildPerCPUArchitecture = false
9662

9763
/**
98-
* Run Proguard to shrink the Java bytecode in release builds.
64+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
9965
*/
10066
def enableProguardInReleaseBuilds = false
10167

10268
/**
103-
* The preferred build flavor of JavaScriptCore.
69+
* The preferred build flavor of JavaScriptCore (JSC)
10470
*
10571
* For example, to use the international variant, you can use:
10672
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
10773
*
10874
* The international variant includes ICU i18n library and necessary data
10975
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
110-
* give correct results when using with locales other than en-US. Note that
76+
* give correct results when using with locales other than en-US. Note that
11177
* this variant is about 6MiB larger per architecture than default.
11278
*/
11379
def jscFlavor = 'org.webkit:android-jsc:+'
11480

11581
/**
116-
* Whether to enable the Hermes VM.
117-
*
118-
* This should be set on project.ext.react and that value will be read here. If it is not set
119-
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
120-
* and the benefits of using Hermes will therefore be sharply reduced.
121-
*/
122-
def enableHermes = project.ext.react.get("enableHermes", false);
123-
124-
/**
125-
* Architectures to build native code for.
82+
* Private function to get the list of Native Architectures you want to build.
83+
* This reads the value from reactNativeArchitectures in your gradle.properties
84+
* file and works together with the --active-arch-only flag of react-native run-android.
12685
*/
12786
def reactNativeArchitectures() {
12887
def value = project.getProperties().get("reactNativeArchitectures")
@@ -134,72 +93,13 @@ android {
13493

13594
compileSdkVersion rootProject.ext.compileSdkVersion
13695

96+
namespace "com.fabricexample"
13797
defaultConfig {
13898
applicationId "com.fabricexample"
13999
minSdkVersion rootProject.ext.minSdkVersion
140100
targetSdkVersion rootProject.ext.targetSdkVersion
141101
versionCode 1
142102
versionName "1.0"
143-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
144-
145-
if (isNewArchitectureEnabled()) {
146-
// We configure the CMake build only if you decide to opt-in for the New Architecture.
147-
externalNativeBuild {
148-
cmake {
149-
arguments "-DPROJECT_BUILD_DIR=$buildDir",
150-
"-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
151-
"-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
152-
"-DNODE_MODULES_DIR=$rootDir/../node_modules",
153-
"-DANDROID_STL=c++_shared"
154-
}
155-
}
156-
if (!enableSeparateBuildPerCPUArchitecture) {
157-
ndk {
158-
abiFilters (*reactNativeArchitectures())
159-
}
160-
}
161-
}
162-
}
163-
164-
if (isNewArchitectureEnabled()) {
165-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
166-
externalNativeBuild {
167-
cmake {
168-
path "$projectDir/src/main/jni/CMakeLists.txt"
169-
}
170-
}
171-
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
172-
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
173-
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
174-
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
175-
into("$buildDir/react-ndk/exported")
176-
}
177-
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
178-
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
179-
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
180-
into("$buildDir/react-ndk/exported")
181-
}
182-
afterEvaluate {
183-
// If you wish to add a custom TurboModule or component locally,
184-
// you should uncomment this line.
185-
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
186-
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
187-
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
188-
189-
// Due to a bug inside AGP, we have to explicitly set a dependency
190-
// between configureCMakeDebug* tasks and the preBuild tasks.
191-
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
192-
configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
193-
configureCMakeDebug.dependsOn(preDebugBuild)
194-
reactNativeArchitectures().each { architecture ->
195-
tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
196-
dependsOn("preDebugBuild")
197-
}
198-
tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
199-
dependsOn("preReleaseBuild")
200-
}
201-
}
202-
}
203103
}
204104

205105
splits {
@@ -249,65 +149,22 @@ android {
249149
}
250150

251151
dependencies {
252-
implementation fileTree(dir: "libs", include: ["*.jar"])
253-
254-
//noinspection GradleDynamicVersion
255-
implementation "com.facebook.react:react-native:+" // From node_modules
256-
257-
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
152+
// The version of react-native is set by the React Native Gradle Plugin
153+
implementation("com.facebook.react:react-android")
258154

259-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
260-
exclude group:'com.facebook.fbjni'
261-
}
155+
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
262156

157+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
263158
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
264-
exclude group:'com.facebook.flipper'
265159
exclude group:'com.squareup.okhttp3', module:'okhttp'
266160
}
267161

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-
}
162+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
163+
if (hermesEnabled.toBoolean()) {
164+
implementation("com.facebook.react:hermes-android")
277165
} else {
278166
implementation jscFlavor
279167
}
280168
}
281169

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-
305-
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-
}
170+
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

0 commit comments

Comments
 (0)