From bd7caa64f5d6ee5ea9484e92c3629c9ce711f73c Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 11 Jan 2022 09:59:23 -0800 Subject: [PATCH] Use side-by-side NDK for Android (#32848) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32848 If we leverage the side-by-side configuration of the NDK (see https://developer.android.com/studio/projects/configure-agp-ndk#agp_version_41) we will not have to specify the NDK Path or Version at all. We will automatically pick the best NDK version selected by AGP. Changelog: [Android] [Changed] - Use side-by-side NDK for Android Reviewed By: ShikaSD Differential Revision: D33475818 fbshipit-source-id: 16aa4acfc44b94e2f92df89d71e104bf46d7f162 --- .circleci/config.yml | 2 -- ReactAndroid/build.gradle | 10 +++++----- build.gradle.kts | 7 ------- gradle.properties | 1 - packages/rn-tester/android/app/build.gradle | 10 +++++----- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cf63979e7bb..b42e3a50442 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -648,7 +648,6 @@ jobs: - ANDROID_BUILD_VERSION: 31 - ANDROID_TOOLS_VERSION: 31.0.0 - GRADLE_OPTS: -Dorg.gradle.daemon=false - - NDK_VERSION: 21.4.7075529 steps: - checkout @@ -694,7 +693,6 @@ jobs: sdkmanager "build-tools;%ANDROID_TOOLS_VERSION%" sdkmanager "add-ons;addon-google_apis-google-23" sdkmanager "extras;android;m2repository" - sdkmanager "ndk;%NDK_VERSION%" # ------------------------- # Run Tests diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index a6d6b74bd74..142cbb70c8f 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -274,11 +274,11 @@ task installArchives { android { compileSdkVersion 31 - if (project.hasProperty("ANDROID_NDK_VERSION")) { - ndkVersion project.property("ANDROID_NDK_VERSION") - } - if (project.hasProperty("ANDROID_NDK_PATH")) { - ndkPath project.property("ANDROID_NDK_PATH") + + // 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") } defaultConfig { diff --git a/build.gradle.kts b/build.gradle.kts index c3ceea9b9e6..7026356079f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,13 +39,6 @@ allprojects { } } } - - // used to override ndk path/version from env variables on CI - ext["ANDROID_NDK_PATH"] = null - if (System.getenv("LOCAL_ANDROID_NDK_VERSION") != null) { - setProperty("ANDROID_NDK_VERSION", System.getenv("LOCAL_ANDROID_NDK_VERSION")) - ext["ANDROID_NDK_PATH"] = System.getenv("ANDROID_NDK") - } } tasks.register("cleanAll", Delete::class.java) { diff --git a/gradle.properties b/gradle.properties index af9ce5ae9b6..5621083a2c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,6 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.parallel=true -ANDROID_NDK_VERSION=21.4.7075529 android.useAndroidX=true kotlin_version=1.5.31 diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index ed425fbe782..aa016e5a10e 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -143,11 +143,11 @@ def reactNativeArchitectures() { android { compileSdkVersion 31 - if (project.hasProperty("ANDROID_NDK_VERSION")) { - ndkVersion project.property("ANDROID_NDK_VERSION") - } - if (project.hasProperty("ANDROID_NDK_PATH")) { - ndkPath project.property("ANDROID_NDK_PATH") + + // 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") } flavorDimensions "vm"