11apply plugin : " com.android.application"
22
33import com.android.build.OutputFile
4+ import org.apache.tools.ant.taskdefs.condition.Os
45
56/**
67 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -78,7 +79,7 @@ import com.android.build.OutputFile
7879 */
7980
8081project. ext. react = [
81- enableHermes : false , // clean and rebuild if changing
82+ enableHermes : true , // clean and rebuild if changing
8283]
8384
8485apply from : " ../../node_modules/react-native/react.gradle"
@@ -142,22 +143,14 @@ android {
142143 buildConfigField " boolean" , " IS_NEW_ARCHITECTURE_ENABLED" , isNewArchitectureEnabled(). toString()
143144
144145 if (isNewArchitectureEnabled()) {
145- // We configure the NDK build only if you decide to opt-in for the New Architecture.
146+ // We configure the CMake build only if you decide to opt-in for the New Architecture.
146147 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"
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"
161154 }
162155 }
163156 if (! enableSeparateBuildPerCPUArchitecture) {
@@ -171,8 +164,8 @@ android {
171164 if (isNewArchitectureEnabled()) {
172165 // We configure the NDK build only if you decide to opt-in for the New Architecture.
173166 externalNativeBuild {
174- ndkBuild {
175- path " $projectDir /src/main/jni/Android.mk "
167+ cmake {
168+ path " $projectDir /src/main/jni/CMakeLists.txt "
176169 }
177170 }
178171 def reactAndroidProjectDir = project(' :ReactAndroid' ). projectDir
@@ -194,15 +187,15 @@ android {
194187 preReleaseBuild. dependsOn(packageReactNdkReleaseLibs)
195188
196189 // Due to a bug inside AGP, we have to explicitly set a dependency
197- // between configureNdkBuild * tasks and the preBuild tasks.
190+ // between configureCMakeDebug * tasks and the preBuild tasks.
198191 // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
199- configureNdkBuildRelease . dependsOn(preReleaseBuild)
200- configureNdkBuildDebug . dependsOn(preDebugBuild)
192+ configureCMakeRelWithDebInfo . dependsOn(preReleaseBuild)
193+ configureCMakeDebug . dependsOn(preDebugBuild)
201194 reactNativeArchitectures(). each { architecture ->
202- tasks. findByName(" configureNdkBuildDebug [${ architecture} ]" )?. configure {
195+ tasks. findByName(" configureCMakeDebug [${ architecture} ]" )?. configure {
203196 dependsOn(" preDebugBuild" )
204197 }
205- tasks. findByName(" configureNdkBuildRelease [${ architecture} ]" )?. configure {
198+ tasks. findByName(" configureCMakeRelWithDebInfo [${ architecture} ]" )?. configure {
206199 dependsOn(" preReleaseBuild" )
207200 }
208201 }
0 commit comments