@@ -2,6 +2,7 @@ apply plugin: "com.android.application"
2
2
apply plugin : " kotlin-android" // manual
3
3
4
4
import com.android.build.OutputFile
5
+ import org.apache.tools.ant.taskdefs.condition.Os
5
6
6
7
/**
7
8
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -143,22 +144,14 @@ android {
143
144
buildConfigField " boolean" , " IS_NEW_ARCHITECTURE_ENABLED" , isNewArchitectureEnabled(). toString()
144
145
145
146
if (isNewArchitectureEnabled()) {
146
- // We configure the NDK build only if you decide to opt-in for the New Architecture.
147
+ // We configure the CMake build only if you decide to opt-in for the New Architecture.
147
148
externalNativeBuild {
148
- ndkBuild {
149
- arguments " APP_PLATFORM=android-21" ,
150
- " APP_STL=c++_shared" ,
151
- " NDK_TOOLCHAIN_VERSION=clang" ,
152
- " GENERATED_SRC_DIR=$buildDir /generated/source" ,
153
- " PROJECT_BUILD_DIR=$buildDir " ,
154
- " REACT_ANDROID_DIR=$rootDir /../node_modules/react-native/ReactAndroid" ,
155
- " REACT_ANDROID_BUILD_DIR=$rootDir /../node_modules/react-native/ReactAndroid/build" ,
156
- " NODE_MODULES_DIR=$rootDir /../node_modules"
157
- cFlags " -Wall" , " -Werror" , " -fexceptions" , " -frtti" , " -DWITH_INSPECTOR=1"
158
- cppFlags " -std=c++17"
159
- // Make sure this target name is the same you specify inside the
160
- // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
161
- targets " enderchat_appmodules"
149
+ cmake {
150
+ arguments " -DPROJECT_BUILD_DIR=$buildDir " ,
151
+ " -DREACT_ANDROID_DIR=$rootDir /../node_modules/react-native/ReactAndroid" ,
152
+ " -DREACT_ANDROID_BUILD_DIR=$rootDir /../node_modules/react-native/ReactAndroid/build" ,
153
+ " -DNODE_MODULES_DIR=$rootDir /../node_modules" ,
154
+ " -DANDROID_STL=c++_shared"
162
155
}
163
156
}
164
157
if (! enableSeparateBuildPerCPUArchitecture) {
@@ -172,8 +165,8 @@ android {
172
165
if (isNewArchitectureEnabled()) {
173
166
// We configure the NDK build only if you decide to opt-in for the New Architecture.
174
167
externalNativeBuild {
175
- ndkBuild {
176
- path " $projectDir /src/main/jni/Android.mk "
168
+ cmake {
169
+ path " $projectDir /src/main/jni/CMakeLists.txt "
177
170
}
178
171
}
179
172
def reactAndroidProjectDir = project(' :ReactAndroid' ). projectDir
@@ -195,15 +188,15 @@ android {
195
188
preReleaseBuild. dependsOn(packageReactNdkReleaseLibs)
196
189
197
190
// Due to a bug inside AGP, we have to explicitly set a dependency
198
- // between configureNdkBuild * tasks and the preBuild tasks.
191
+ // between configureCMakeDebug * tasks and the preBuild tasks.
199
192
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
200
- configureNdkBuildRelease . dependsOn(preReleaseBuild)
201
- configureNdkBuildDebug . dependsOn(preDebugBuild)
193
+ configureCMakeRelWithDebInfo . dependsOn(preReleaseBuild)
194
+ configureCMakeDebug . dependsOn(preDebugBuild)
202
195
reactNativeArchitectures(). each { architecture ->
203
- tasks. findByName(" configureNdkBuildDebug [${ architecture} ]" )?. configure {
196
+ tasks. findByName(" configureCMakeDebug [${ architecture} ]" )?. configure {
204
197
dependsOn(" preDebugBuild" )
205
198
}
206
- tasks. findByName(" configureNdkBuildRelease [${ architecture} ]" )?. configure {
199
+ tasks. findByName(" configureCMakeRelWithDebInfo [${ architecture} ]" )?. configure {
207
200
dependsOn(" preReleaseBuild" )
208
201
}
209
202
}
0 commit comments