11apply plugin : " com.android.application"
22
33import com.android.build.OutputFile
4- import org.apache.tools.ant.taskdefs.condition.Os
54
65/**
76 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -151,27 +150,14 @@ android {
151150 buildConfigField " boolean" , " IS_NEW_ARCHITECTURE_ENABLED" , isNewArchitectureEnabled(). toString()
152151
153152 if (isNewArchitectureEnabled()) {
154- // We configure the NDK build only if you decide to opt-in for the New Architecture.
153+ // We configure the CMake build only if you decide to opt-in for the New Architecture.
155154 externalNativeBuild {
156- ndkBuild {
157- arguments " APP_PLATFORM=android-21" ,
158- " APP_STL=c++_shared" ,
159- " NDK_TOOLCHAIN_VERSION=clang" ,
160- " GENERATED_SRC_DIR=$buildDir /generated/source" ,
161- " PROJECT_BUILD_DIR=$buildDir " ,
162- " REACT_ANDROID_DIR=${ reactNativeRoot} /ReactAndroid" ,
163- " REACT_ANDROID_BUILD_DIR=${ reactNativeRoot} /ReactAndroid/build" ,
164- " NODE_MODULES_DIR=$rootDir /../node_modules"
165- cFlags " -Wall" , " -Werror" , " -fexceptions" , " -frtti" , " -DWITH_INSPECTOR=1"
166- cppFlags " -std=c++17"
167- // Make sure this target name is the same you specify inside the
168- // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
169- targets " expomessaging_appmodules"
170-
171- // Fix for windows limit on number of character in file paths and in command lines
172- if (Os . isFamily(Os . FAMILY_WINDOWS )) {
173- arguments " NDK_APP_SHORT_COMMANDS=true"
174- }
155+ cmake {
156+ arguments " -DPROJECT_BUILD_DIR=$buildDir " ,
157+ " -DREACT_ANDROID_DIR=${ reactNativeRoot} /ReactAndroid" ,
158+ " -DREACT_ANDROID_BUILD_DIR=${ reactNativeRoot} /ReactAndroid/build" ,
159+ " -DNODE_MODULES_DIR=$rootDir /../node_modules" ,
160+ " -DANDROID_STL=c++_shared"
175161 }
176162 }
177163 if (! enableSeparateBuildPerCPUArchitecture) {
@@ -183,10 +169,10 @@ android {
183169 }
184170
185171 if (isNewArchitectureEnabled()) {
186- // We configure the NDK build only if you decide to opt-in for the New Architecture.
172+ // We configure the CMake build only if you decide to opt-in for the New Architecture.
187173 externalNativeBuild {
188- ndkBuild {
189- path " $projectDir /src/main/jni/Android.mk "
174+ cmake {
175+ path " $projectDir /src/main/jni/CMakeLists.txt "
190176 }
191177 }
192178 def reactAndroidProjectDir = project(' :ReactAndroid' ). projectDir
@@ -208,15 +194,15 @@ android {
208194 preReleaseBuild. dependsOn(packageReactNdkReleaseLibs)
209195
210196 // Due to a bug inside AGP, we have to explicitly set a dependency
211- // between configureNdkBuild * tasks and the preBuild tasks.
197+ // between configureCMakeDebug * tasks and the preBuild tasks.
212198 // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
213- configureNdkBuildRelease . dependsOn(preReleaseBuild)
214- configureNdkBuildDebug . dependsOn(preDebugBuild)
199+ configureCMakeRelWithDebInfo . dependsOn(preReleaseBuild)
200+ configureCMakeDebug . dependsOn(preDebugBuild)
215201 reactNativeArchitectures(). each { architecture ->
216- tasks. findByName(" configureNdkBuildDebug [${ architecture} ]" )?. configure {
202+ tasks. findByName(" configureCMakeDebug [${ architecture} ]" )?. configure {
217203 dependsOn(" preDebugBuild" )
218204 }
219- tasks. findByName(" configureNdkBuildRelease [${ architecture} ]" )?. configure {
205+ tasks. findByName(" configureCMakeRelWithDebInfo [${ architecture} ]" )?. configure {
220206 dependsOn(" preReleaseBuild" )
221207 }
222208 }
0 commit comments