Skip to content

Commit 43c38cd

Browse files
neildharfacebook-github-bot
authored andcommitted
Allow specifying an architecture in RNTester and release builds
Summary: Setting `reactNativeDebugArchitectures` currently does not seem to work for RNTester, since it sets `abiFilters` which conflicts with the `splits` option we're already setting. Gradle then complains: ``` neildhar@neildhar-mbp ~/f/x/j/react-native-github (default) > ./gradlew -PreactNativeDebugArchitectures=x86_64 :packages:rn-tester:android:app:installJscDebug > Configure project :ReactAndroid Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version. Class name for the included build object: org.gradle.composite.internal.DefaultIncludedBuild$IncludedBuildImpl_Decorated. FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':packages:rn-tester:android:app'. > com.android.builder.errors.EvalIssueException: Conflicting configuration : 'x86_64' in ndk abiFilters cannot be present when splits abi filters are set : x86_64,x86,armeabi-v7a,arm64-v8a ``` Consolidate everything with the `splits` option. In addition, it's convenient to also be able to control the native architecture for release builds. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D31834075 fbshipit-source-id: c6375d2a1e242981d0017f6e0a9d428b074a3fbd
1 parent 8649174 commit 43c38cd

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

ReactAndroid/build.gradle

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,8 @@ def reactNativeInspectorProxyPort() {
224224
}
225225

226226
def reactNativeArchitectures() {
227-
def isDebug = gradle.startParameter.taskRequests.any {
228-
it.args.any { it.endsWith("Debug") }
229-
}
230-
def value = project.getProperties().get("reactNativeDebugArchitectures")
231-
return value != null && isDebug ? value : "all"
227+
def value = project.getProperties().get("reactNativeArchitectures")
228+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
232229
}
233230

234231
def ndkBuildJobs() {
@@ -290,8 +287,7 @@ android {
290287

291288
externalNativeBuild {
292289
ndkBuild {
293-
arguments "APP_ABI=${reactNativeArchitectures()}",
294-
"NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
290+
arguments "NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
295291
"THIRD_PARTY_NDK_DIR=$thirdPartyNdkDir",
296292
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
297293
"REACT_GENERATED_SRC_DIR=$buildDir/generated/source",
@@ -304,6 +300,9 @@ android {
304300
}
305301
}
306302
}
303+
ndk {
304+
abiFilters (*reactNativeArchitectures())
305+
}
307306
}
308307

309308
externalNativeBuild {

packages/rn-tester/android/app/build.gradle

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ def enableFabric = project.ext.react.enableFabric
133133
def useIntlJsc = false
134134

135135
/**
136-
* Architectures to build native code for in debug.
136+
* Architectures to build native code for.
137137
*/
138-
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
138+
def nativeArchitectures = project.getProperties().get("reactNativeArchitectures") ?
139+
project.getProperties().get("reactNativeArchitectures").split(",")
140+
: ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
139141

140142
android {
141143
compileSdkVersion 29
@@ -183,18 +185,13 @@ android {
183185
enable enableSeparateBuildPerCPUArchitecture
184186
universalApk false
185187
reset()
186-
include "armeabi-v7a", "x86", "x86_64", "arm64-v8a"
188+
include (*nativeArchitectures)
187189
}
188190
}
189191
buildTypes {
190192
debug {
191193
debuggable true
192194
signingConfig signingConfigs.release
193-
if (nativeArchitectures) {
194-
ndk {
195-
abiFilters nativeArchitectures.split(',')
196-
}
197-
}
198195
}
199196
release {
200197
debuggable false

template/android/app/build.gradle

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ def jscFlavor = 'org.webkit:android-jsc:+'
121121
def enableHermes = project.ext.react.get("enableHermes", false);
122122

123123
/**
124-
* Architectures to build native code for in debug.
124+
* Architectures to build native code for.
125125
*/
126-
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
127-
126+
def nativeArchitectures = project.getProperties().get("reactNativeArchitectures") ?
127+
project.getProperties().get("reactNativeArchitectures").split(",")
128+
: ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
128129
android {
129130
ndkVersion rootProject.ext.ndkVersion
130131

@@ -142,7 +143,7 @@ android {
142143
reset()
143144
enable enableSeparateBuildPerCPUArchitecture
144145
universalApk false // If true, also generate a universal APK
145-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
146+
include (*nativeArchitectures)
146147
}
147148
}
148149
signingConfigs {
@@ -156,11 +157,6 @@ android {
156157
buildTypes {
157158
debug {
158159
signingConfig signingConfigs.debug
159-
if (nativeArchitectures) {
160-
ndk {
161-
abiFilters nativeArchitectures.split(',')
162-
}
163-
}
164160
}
165161
release {
166162
// Caution! In production, you need to generate your own keystore file.

0 commit comments

Comments
 (0)