mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Improve support for Android users on M1 machine (#33588)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/33588 Currently users on M1 machine can't use the New Architecture correctly as they will get build failures when building the native code. This Diff fixes it by automatically recognizing the host architecture and switching to NDK 24 if user is runnign on `aarch64` Changelog: [Android] [Fixed] - Improve support for Android users on M1 machine Reviewed By: mdvacca Differential Revision: D35468252 fbshipit-source-id: b73f5262b9408f04f3ae4fd26458a4d17c1ec29a
This commit is contained in:
@@ -281,10 +281,13 @@ task androidSourcesJar(type: Jar) {
|
||||
android {
|
||||
compileSdkVersion 31
|
||||
|
||||
// Used to override the NDK path & version on internal CI
|
||||
if (System.getenv("ANDROID_NDK") != null && System.getenv("LOCAL_ANDROID_NDK_VERSION") != null) {
|
||||
ndkPath System.getenv("ANDROID_NDK")
|
||||
ndkVersion System.getenv("LOCAL_ANDROID_NDK_VERSION")
|
||||
// Used to override the NDK path/version on internal CI or by allowing
|
||||
// users to customize the NDK path/version from their root project (e.g. for M1 support)
|
||||
if (rootProject.hasProperty("ndkPath")) {
|
||||
ndkPath rootProject.ext.ndkPath
|
||||
}
|
||||
if (rootProject.hasProperty("ndkVersion")) {
|
||||
ndkVersion rootProject.ext.ndkVersion
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
val ndkPath by extra(System.getenv("ANDROID_NDK"))
|
||||
val ndkVersion by extra(System.getenv("ANDROID_NDK_VERSION"))
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
|
||||
@@ -145,10 +145,13 @@ def reactNativeArchitectures() {
|
||||
android {
|
||||
compileSdkVersion 31
|
||||
|
||||
// Used to override the NDK path & version on internal CI
|
||||
if (System.getenv("ANDROID_NDK") != null && System.getenv("LOCAL_ANDROID_NDK_VERSION") != null) {
|
||||
ndkPath System.getenv("ANDROID_NDK")
|
||||
ndkVersion System.getenv("LOCAL_ANDROID_NDK_VERSION")
|
||||
// Used to override the NDK path/version on internal CI or by allowing
|
||||
// users to customize the NDK path/version from their root project (e.g. for M1 support)
|
||||
if (rootProject.hasProperty("ndkPath")) {
|
||||
ndkPath rootProject.ext.ndkPath
|
||||
}
|
||||
if (rootProject.hasProperty("ndkVersion")) {
|
||||
ndkVersion rootProject.ext.ndkVersion
|
||||
}
|
||||
|
||||
flavorDimensions "vm"
|
||||
|
||||
@@ -6,7 +6,13 @@ buildscript {
|
||||
minSdkVersion = 21
|
||||
compileSdkVersion = 31
|
||||
targetSdkVersion = 31
|
||||
ndkVersion = "21.4.7075529"
|
||||
// For M1 Users we need to use the NDK 24, otherwise we default to the
|
||||
// side-by-side NDK version from AGP.
|
||||
if (System.properties['os.arch'] == "aarch64") {
|
||||
ndkVersion = "24.0.8215888"
|
||||
} else {
|
||||
ndkVersion = "21.4.7075529"
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
google()
|
||||
|
||||
Reference in New Issue
Block a user