diff --git a/gradle.properties b/gradle.properties index 4d0bece201bd22..af9ce5ae9b642f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,3 +7,8 @@ org.gradle.parallel=true ANDROID_NDK_VERSION=21.4.7075529 android.useAndroidX=true kotlin_version=1.5.31 + +# Use this property to specify which architecture you want to build. +# You can also override it from the CLI using +# ./gradlew -PreactNativeArchitectures=x86_64 +reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index 7a2303617a824f..a2de00ba8fec3b 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -135,9 +135,10 @@ def useIntlJsc = false /** * Architectures to build native code for. */ -def nativeArchitectures = project.getProperties().get("reactNativeArchitectures") ? - project.getProperties().get("reactNativeArchitectures").split(",") - : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] +def reactNativeArchitectures() { + def value = project.getProperties().get("reactNativeArchitectures") + return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] +} android { compileSdkVersion 29 @@ -185,7 +186,7 @@ android { enable enableSeparateBuildPerCPUArchitecture universalApk false reset() - include (*nativeArchitectures) + include (*reactNativeArchitectures()) } } buildTypes { diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle index 04130f5c7130df..e1c91549c43251 100644 --- a/template/android/app/build.gradle +++ b/template/android/app/build.gradle @@ -123,9 +123,11 @@ def enableHermes = project.ext.react.get("enableHermes", false); /** * Architectures to build native code for. */ -def nativeArchitectures = project.getProperties().get("reactNativeArchitectures") ? - project.getProperties().get("reactNativeArchitectures").split(",") - : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] +def reactNativeArchitectures() { + def value = project.getProperties().get("reactNativeArchitectures") + return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] +} + android { ndkVersion rootProject.ext.ndkVersion @@ -143,7 +145,7 @@ android { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK - include (*nativeArchitectures) + include (*reactNativeArchitectures()) } } signingConfigs { diff --git a/template/android/gradle.properties b/template/android/gradle.properties index 11d6e02418e0b4..389db0c188079c 100644 --- a/template/android/gradle.properties +++ b/template/android/gradle.properties @@ -26,3 +26,8 @@ android.enableJetifier=true # Version of flipper SDK to use with React Native FLIPPER_VERSION=0.99.0 + +# Use this property to specify which architecture you want to build. +# You can also override it from the CLI using +# ./gradlew -PreactNativeArchitectures=x86_64 +reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64