Skip to content

Commit 24c4f82

Browse files
committed
feat: version 4 with react native 71 upgrade on android
1 parent ba38cc7 commit 24c4f82

31 files changed

+12884
-10360
lines changed

.buckconfig

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

.gitignore

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,17 @@ build/
2929
.gradle
3030
local.properties
3131
*.iml
32-
33-
# Visual Studio Code
34-
#
35-
.vscode/
32+
*.hprof
33+
.cxx/
34+
*.keystore
35+
!debug.keystore
3636

3737
# node.js
3838
#
3939
node_modules/
4040
npm-debug.log
4141
yarn-error.log
4242

43-
# BUCK
44-
buck-out/
45-
\.buckd/
46-
*.keystore
47-
!debug.keystore
48-
4943
# fastlane
5044
#
5145
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
@@ -61,5 +55,9 @@ buck-out/
6155
# Bundle artifact
6256
*.jsbundle
6357

64-
# CocoaPods
58+
# Ruby / CocoaPods
6559
/ios/Pods/
60+
/vendor/bundle/
61+
62+
# Temporary files created by Metro to check the health of the file watcher
63+
.metro-health-check*

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.7.5
1+
2.7.6

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 File.read(File.join(__dir__, '.ruby-version')).strip
55

6-
gem 'cocoapods', '~> 1.11', '>= 1.11.2'
6+
gem 'cocoapods', '~> 1.11', '>= 1.11.3'

android/app/_BUCK

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

android/app/build.gradle

Lines changed: 84 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,89 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "com.facebook.react"
23
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
34

45
import com.android.build.OutputFile
56

6-
project.ext.react = [
7-
enableHermes: false, // clean and rebuild if changing
8-
]
9-
10-
apply from: "../../node_modules/react-native/react.gradle"
7+
/**
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.
10+
*/
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+
}
1155

56+
/**
57+
* Set this to true to create four separate APKs instead of one,
58+
* one for each native architecture. This is useful if you don't
59+
* use App Bundles (https://developer.android.com/guide/app-bundle/)
60+
* and want to have separate APKs to upload to the Play Store.
61+
*/
1262
def enableSeparateBuildPerCPUArchitecture = false
63+
64+
/**
65+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
66+
*/
1367
def enableProguardInReleaseBuilds = false
68+
69+
/**
70+
* The preferred build flavor of JavaScriptCore (JSC)
71+
*
72+
* For example, to use the international variant, you can use:
73+
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
74+
*
75+
* The international variant includes ICU i18n library and necessary data
76+
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
77+
* give correct results when using with locales other than en-US. Note that
78+
* this variant is about 6MiB larger per architecture than default.
79+
*/
1480
def jscFlavor = 'org.webkit:android-jsc:+'
15-
def enableHermes = project.ext.react.get("enableHermes", false);
1681

82+
/**
83+
* Private function to get the list of Native Architectures you want to build.
84+
* This reads the value from reactNativeArchitectures in your gradle.properties
85+
* file and works together with the --active-arch-only flag of react-native run-android.
86+
*/
1787
def reactNativeArchitectures() {
1888
def value = project.getProperties().get("reactNativeArchitectures")
1989
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
@@ -24,86 +94,13 @@ android {
2494

2595
compileSdkVersion rootProject.ext.compileSdkVersion
2696

27-
// ? You can remove if you don't want to use JAVA Version 18
28-
compileOptions {
29-
sourceCompatibility JavaVersion.VERSION_1_8
30-
targetCompatibility JavaVersion.VERSION_1_8
31-
}
32-
97+
namespace "com.rntypescriptboilerplate"
3398
defaultConfig {
3499
applicationId "com.rntypescriptboilerplate"
35100
minSdkVersion rootProject.ext.minSdkVersion
36101
targetSdkVersion rootProject.ext.targetSdkVersion
37102
versionCode 1
38103
versionName "1.0"
39-
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
40-
41-
if (isNewArchitectureEnabled()) {
42-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
43-
externalNativeBuild {
44-
ndkBuild {
45-
arguments "APP_PLATFORM=android-21",
46-
"APP_STL=c++_shared",
47-
"NDK_TOOLCHAIN_VERSION=clang",
48-
"GENERATED_SRC_DIR=$buildDir/generated/source",
49-
"PROJECT_BUILD_DIR=$buildDir",
50-
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
51-
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
52-
"NODE_MODULES_DIR=$rootDir/../node_modules"
53-
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
54-
cppFlags "-std=c++17"
55-
// Make sure this target name is the same you specify inside the
56-
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
57-
targets "rntypescriptboilerplate_appmodules"
58-
}
59-
}
60-
if (!enableSeparateBuildPerCPUArchitecture) {
61-
ndk {
62-
abiFilters (*reactNativeArchitectures())
63-
}
64-
}
65-
}
66-
}
67-
68-
if (isNewArchitectureEnabled()) {
69-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
70-
externalNativeBuild {
71-
ndkBuild {
72-
path "$projectDir/src/main/jni/Android.mk"
73-
}
74-
}
75-
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
76-
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
77-
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
78-
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
79-
into("$buildDir/react-ndk/exported")
80-
}
81-
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
82-
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
83-
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
84-
into("$buildDir/react-ndk/exported")
85-
}
86-
afterEvaluate {
87-
// If you wish to add a custom TurboModule or component locally,
88-
// you should uncomment this line.
89-
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
90-
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
91-
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
92-
93-
// Due to a bug inside AGP, we have to explicitly set a dependency
94-
// between configureNdkBuild* tasks and the preBuild tasks.
95-
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
96-
configureNdkBuildRelease.dependsOn(preReleaseBuild)
97-
configureNdkBuildDebug.dependsOn(preDebugBuild)
98-
reactNativeArchitectures().each { architecture ->
99-
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
100-
dependsOn("preDebugBuild")
101-
}
102-
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
103-
dependsOn("preReleaseBuild")
104-
}
105-
}
106-
}
107104
}
108105

109106
splits {
@@ -150,77 +147,25 @@ android {
150147

151148
}
152149
}
153-
154-
packagingOptions {
155-
pickFirst '**/armeabi-v7a/libc++_shared.so'
156-
pickFirst '**/x86/libc++_shared.so'
157-
pickFirst '**/arm64-v8a/libc++_shared.so'
158-
pickFirst '**/x86_64/libc++_shared.so'
159-
pickFirst '**/x86/libjsc.so'
160-
pickFirst '**/armeabi-v7a/libjsc.so'
161-
}
162150
}
163151

164152
dependencies {
165-
implementation fileTree(dir: "libs", include: ["*.jar"])
166-
167-
//noinspection GradleDynamicVersion
168-
implementation "com.facebook.react:react-native:+" // From node_modules
169-
170-
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
153+
// The version of react-native is set by the React Native Gradle Plugin
154+
implementation("com.facebook.react:react-android")
171155

172-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
173-
exclude group:'com.facebook.fbjni'
174-
}
156+
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
175157

158+
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
176159
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
177-
exclude group:'com.facebook.flipper'
178160
exclude group:'com.squareup.okhttp3', module:'okhttp'
179161
}
180162

181-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
182-
exclude group:'com.facebook.flipper'
183-
}
184-
185-
if (enableHermes) {
186-
//noinspection GradleDynamicVersion
187-
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
188-
exclude group:'com.facebook.fbjni'
189-
}
163+
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
164+
if (hermesEnabled.toBoolean()) {
165+
implementation("com.facebook.react:hermes-android")
190166
} else {
191167
implementation jscFlavor
192168
}
193169
}
194170

195-
if (isNewArchitectureEnabled()) {
196-
// If new architecture is enabled, we let you build RN from source
197-
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
198-
// This will be applied to all the imported transtitive dependency.
199-
configurations.all {
200-
resolutionStrategy.dependencySubstitution {
201-
substitute(module("com.facebook.react:react-native"))
202-
.using(project(":ReactAndroid"))
203-
.because("On New Architecture we're building React Native from source")
204-
substitute(module("com.facebook.react:hermes-engine"))
205-
.using(project(":ReactAndroid:hermes-engine"))
206-
.because("On New Architecture we're building Hermes from source")
207-
}
208-
}
209-
}
210-
211-
// Run this once to be able to run the application with BUCK
212-
// puts all compile dependencies into folder libs for BUCK to use
213-
task copyDownloadableDepsToLibs(type: Copy) {
214-
from configurations.implementation
215-
into 'libs'
216-
}
217-
218171
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
219-
220-
def isNewArchitectureEnabled() {
221-
// To opt-in for the New Architecture, you can either:
222-
// - Set `newArchEnabled` to true inside the `gradle.properties` file
223-
// - Invoke gradle with `-newArchEnabled=true`
224-
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
225-
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
226-
}

0 commit comments

Comments
 (0)