Skip to content

Commit c62384f

Browse files
authored
chore: update react-native0.69.3 to react-native0.70.5 (#223)
* chore: update react-native0.69.3 to react-native0.70.5 * doc: update README * fix: 修复android运行报错
1 parent beb77eb commit c62384f

36 files changed

+262
-959
lines changed

HelloWorld/.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ untyped-import
6363
untyped-type-import
6464

6565
[version]
66-
^0.176.3
66+
^0.182.0

HelloWorld/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ build/
3030
local.properties
3131
*.iml
3232
*.hprof
33-
33+
.cxx/
3434
# node.js
3535
#
3636
node_modules/

HelloWorld/.node-version

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

HelloWorld/android/app/build.gradle

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apply plugin: "com.android.application"
2-
32
import com.android.build.OutputFile
3+
import org.apache.tools.ant.taskdefs.condition.Os
44

55
/**
66
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -78,7 +78,7 @@ import com.android.build.OutputFile
7878
*/
7979

8080
project.ext.react = [
81-
enableHermes: false, // clean and rebuild if changing
81+
enableHermes: true, // clean and rebuild if changing
8282
]
8383

8484
apply from: "../../node_modules/react-native/react.gradle"
@@ -142,22 +142,14 @@ android {
142142
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
143143

144144
if (isNewArchitectureEnabled()) {
145-
// We configure the NDK build only if you decide to opt-in for the New Architecture.
145+
// We configure the CMake build only if you decide to opt-in for the New Architecture.
146146
externalNativeBuild {
147-
ndkBuild {
148-
arguments "APP_PLATFORM=android-21",
149-
"APP_STL=c++_shared",
150-
"NDK_TOOLCHAIN_VERSION=clang",
151-
"GENERATED_SRC_DIR=$buildDir/generated/source",
152-
"PROJECT_BUILD_DIR=$buildDir",
153-
"REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
154-
"REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
155-
"NODE_MODULES_DIR=$rootDir/../node_modules"
156-
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
157-
cppFlags "-std=c++17"
158-
// Make sure this target name is the same you specify inside the
159-
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
160-
targets "helloworld_appmodules"
147+
cmake {
148+
arguments "-DPROJECT_BUILD_DIR=$buildDir",
149+
"-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
150+
"-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
151+
"-DNODE_MODULES_DIR=$rootDir/../node_modules",
152+
"-DANDROID_STL=c++_shared"
161153
}
162154
}
163155
if (!enableSeparateBuildPerCPUArchitecture) {
@@ -171,8 +163,8 @@ android {
171163
if (isNewArchitectureEnabled()) {
172164
// We configure the NDK build only if you decide to opt-in for the New Architecture.
173165
externalNativeBuild {
174-
ndkBuild {
175-
path "$projectDir/src/main/jni/Android.mk"
166+
cmake {
167+
path "$projectDir/src/main/jni/CMakeLists.txt"
176168
}
177169
}
178170
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
@@ -194,15 +186,15 @@ android {
194186
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
195187

196188
// Due to a bug inside AGP, we have to explicitly set a dependency
197-
// between configureNdkBuild* tasks and the preBuild tasks.
189+
// between configureCMakeDebug* tasks and the preBuild tasks.
198190
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
199-
configureNdkBuildRelease.dependsOn(preReleaseBuild)
200-
configureNdkBuildDebug.dependsOn(preDebugBuild)
191+
configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
192+
configureCMakeDebug.dependsOn(preDebugBuild)
201193
reactNativeArchitectures().each { architecture ->
202-
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
194+
tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
203195
dependsOn("preDebugBuild")
204196
}
205-
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
197+
tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
206198
dependsOn("preReleaseBuild")
207199
}
208200
}

HelloWorld/android/app/src/main/jni/Android.mk

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
# Define the library name here.
3+
project(rndiffapp_appmodules)
4+
# This file includes all the necessary to let you build your application with the New Architecture.
5+
include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)

HelloWorld/android/app/src/main/jni/MainApplicationModuleProvider.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#include "MainApplicationModuleProvider.h"
22

3+
#include <rncli.h>
34
#include <rncore.h>
45

56
namespace facebook {
67
namespace react {
78

89
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
9-
const std::string moduleName,
10+
const std::string &moduleName,
1011
const JavaTurboModule::InitParams &params) {
1112
// Here you can provide your own module provider for TurboModules coming from
1213
// either your application or from external libraries. The approach to follow
@@ -17,6 +18,12 @@ std::shared_ptr<TurboModule> MainApplicationModuleProvider(
1718
// return module;
1819
// }
1920
// return rncore_ModuleProvider(moduleName, params);
21+
22+
// Module providers autolinked by RN CLI
23+
auto rncli_module = rncli_ModuleProvider(moduleName, params);
24+
if (rncli_module != nullptr) {
25+
return rncli_module;
26+
}
2027
return rncore_ModuleProvider(moduleName, params);
2128
}
2229

HelloWorld/android/app/src/main/jni/MainApplicationModuleProvider.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace facebook {
99
namespace react {
1010

1111
std::shared_ptr<TurboModule> MainApplicationModuleProvider(
12-
const std::string moduleName,
12+
const std::string &moduleName,
1313
const JavaTurboModule::InitParams &params);
1414

1515
} // namespace react

HelloWorld/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ void MainApplicationTurboModuleManagerDelegate::registerNatives() {
2222

2323
std::shared_ptr<TurboModule>
2424
MainApplicationTurboModuleManagerDelegate::getTurboModule(
25-
const std::string name,
26-
const std::shared_ptr<CallInvoker> jsInvoker) {
25+
const std::string &name,
26+
const std::shared_ptr<CallInvoker> &jsInvoker) {
2727
// Not implemented yet: provide pure-C++ NativeModules here.
2828
return nullptr;
2929
}
3030

3131
std::shared_ptr<TurboModule>
3232
MainApplicationTurboModuleManagerDelegate::getTurboModule(
33-
const std::string name,
33+
const std::string &name,
3434
const JavaTurboModule::InitParams &params) {
3535
return MainApplicationModuleProvider(name, params);
3636
}
3737

3838
bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
39-
std::string name) {
39+
const std::string &name) {
4040
return getTurboModule(name, nullptr) != nullptr ||
4141
getTurboModule(name, {.moduleName = name}) != nullptr;
4242
}

HelloWorld/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ class MainApplicationTurboModuleManagerDelegate
2121
static void registerNatives();
2222

2323
std::shared_ptr<TurboModule> getTurboModule(
24-
const std::string name,
25-
const std::shared_ptr<CallInvoker> jsInvoker) override;
24+
const std::string &name,
25+
const std::shared_ptr<CallInvoker> &jsInvoker) override;
2626
std::shared_ptr<TurboModule> getTurboModule(
27-
const std::string name,
27+
const std::string &name,
2828
const JavaTurboModule::InitParams &params) override;
2929

3030
/**
3131
* Test-only method. Allows user to verify whether a TurboModule can be
3232
* created by instances of this class.
3333
*/
34-
bool canCreateTurboModule(std::string name);
34+
bool canCreateTurboModule(const std::string &name);
3535
};
3636

3737
} // namespace react

0 commit comments

Comments
 (0)