From 0cadd6860f1b2a831efd8c76334b337ade64c819 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Tue, 23 Nov 2021 04:37:44 -0800 Subject: [PATCH] Bump OSS Android build to SDK 31 (#32606) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32606 Updates OSS builds for internals and template to target SDK 31, corresponding to Android 12. Changelog: [Updated][Android] - Bump Android compile and target SDK to 31 Reviewed By: cortinico Differential Revision: D32107409 fbshipit-source-id: b8f9acaae70cd25518b9bf9492d5d1e1d2ec7ab8 --- .circleci/Dockerfiles/Dockerfile.android | 2 +- .circleci/config.yml | 6 +++--- ReactAndroid/build.gradle | 4 ++-- ReactAndroid/src/androidTest/AndroidManifest.xml | 1 + .../src/androidTest/buck-runner/AndroidManifest.xml | 3 ++- .../facebook/react/devsupport/BridgeDevSupportManager.java | 2 +- package.json | 2 +- .../src/test/kotlin/com/facebook/react/ReactPluginTest.kt | 6 +++--- packages/rn-tester/android/app/build.gradle | 4 ++-- packages/rn-tester/android/app/src/main/AndroidManifest.xml | 5 +++-- scripts/.tests.env | 6 +++--- template/android/app/src/debug/AndroidManifest.xml | 2 +- template/android/app/src/main/AndroidManifest.xml | 3 ++- template/android/build.gradle | 6 +++--- 14 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.circleci/Dockerfiles/Dockerfile.android b/.circleci/Dockerfiles/Dockerfile.android index 822d7df3d2983a..262c4f8ebfaef8 100644 --- a/.circleci/Dockerfiles/Dockerfile.android +++ b/.circleci/Dockerfiles/Dockerfile.android @@ -14,7 +14,7 @@ # and build a Android application that can be used to run the # tests specified in the scripts/ directory. # -FROM reactnativecommunity/react-native-android:5.1 +FROM reactnativecommunity/react-native-android:5.2 LABEL Description="React Native Android Test Image" LABEL maintainer="Héctor Ramos " diff --git a/.circleci/config.yml b/.circleci/config.yml index 03108bff69efd5..8558724dbeff92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -36,7 +36,7 @@ executors: reactnativeandroid: <<: *defaults docker: - - image: reactnativecommunity/react-native-android:5.1 + - image: reactnativecommunity/react-native-android:5.2 resource_class: "large" environment: - TERM: "dumb" @@ -649,8 +649,8 @@ jobs: environment: - ANDROID_HOME: "C:\\Android\\android-sdk" - ANDROID_NDK: "C:\\Android\\android-sdk\\ndk\\20.1.5948944" - - ANDROID_BUILD_VERSION: 30 - - ANDROID_TOOLS_VERSION: 30.0.2 + - ANDROID_BUILD_VERSION: 31 + - ANDROID_TOOLS_VERSION: 31.0.0 - GRADLE_OPTS: -Dorg.gradle.daemon=false - NDK_VERSION: 21.4.7075529 steps: diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index aaaecada49e8e0..3c2771b04b8c1e 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -281,7 +281,7 @@ task installArchives { } android { - compileSdkVersion 30 + compileSdkVersion 31 if (project.hasProperty("ANDROID_NDK_VERSION")) { ndkVersion project.property("ANDROID_NDK_VERSION") } @@ -291,7 +291,7 @@ android { defaultConfig { minSdkVersion(21) - targetSdkVersion(28) + targetSdkVersion(31) versionCode(1) versionName("1.0") diff --git a/ReactAndroid/src/androidTest/AndroidManifest.xml b/ReactAndroid/src/androidTest/AndroidManifest.xml index 0ebc7b4768ecba..31552b1abc0ba2 100644 --- a/ReactAndroid/src/androidTest/AndroidManifest.xml +++ b/ReactAndroid/src/androidTest/AndroidManifest.xml @@ -14,6 +14,7 @@ diff --git a/ReactAndroid/src/androidTest/buck-runner/AndroidManifest.xml b/ReactAndroid/src/androidTest/buck-runner/AndroidManifest.xml index 49b4a1fc433c31..5e31d4403b2d20 100644 --- a/ReactAndroid/src/androidTest/buck-runner/AndroidManifest.xml +++ b/ReactAndroid/src/androidTest/buck-runner/AndroidManifest.xml @@ -15,7 +15,8 @@ + android:theme="@style/Theme.ReactNative.AppCompat.Light.NoActionBar.FullScreen" + android:exported="false"> diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java index 30c0840f90dfb8..ea1b53c83ebcf5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java @@ -58,7 +58,7 @@ * * IMPORTANT: In order for developer support to work correctly it is required that the * manifest of your application contain the following entries: - * {@code } + * {@code } * {@code } */ public final class BridgeDevSupportManager extends DevSupportManagerBase { diff --git a/package.json b/package.json index d6aa7bf9f0204d..1b963d64aec565 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "prettier": "prettier --write \"./**/*.{js,md,yml}\"", "format-check": "prettier --list-different \"./**/*.{js,md,yml}\"", "update-lock": "npx yarn-deduplicate", - "docker-setup-android": "docker pull reactnativecommunity/react-native-android:5.1", + "docker-setup-android": "docker pull reactnativecommunity/react-native-android:5.2", "docker-build-android": "docker build -t reactnativeci/android -f .circleci/Dockerfiles/Dockerfile.android .", "test-android-run-instrumentation": "docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash .circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh", "test-android-run-unit": "docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash .circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh", diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt index 602dd522f40960..1bf7fd5a1c112e 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/ReactPluginTest.kt @@ -20,7 +20,7 @@ class ReactPluginTest { project.plugins.apply("com.android.application") project.plugins.apply("com.facebook.react") - project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(30) } + project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(31) } project.extensions.getByType(ReactExtension::class.java).apply { applyAppPlugin.set(true) cliPath.set(".") @@ -36,7 +36,7 @@ class ReactPluginTest { project.plugins.apply("com.android.application") project.plugins.apply("com.facebook.react") - project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(30) } + project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(31) } project.extensions.getByType(ReactExtension::class.java).apply { applyAppPlugin.set(false) } assertTrue(project.getTasksByName("bundleDebugJsAndAssets", false).isEmpty()) @@ -48,7 +48,7 @@ class ReactPluginTest { project.plugins.apply("com.android.application") project.plugins.apply("com.facebook.react") - project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(30) } + project.extensions.getByType(AppExtension::class.java).apply { compileSdkVersion(31) } project.extensions.getByType(ReactExtension::class.java).apply { applyAppPlugin.set(false) } assertTrue(project.getTasksByName("buildCodegenCLI", false).isNotEmpty()) diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index 6243d565237457..ec27d3b42b2116 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -142,7 +142,7 @@ def reactNativeArchitectures() { } android { - compileSdkVersion 29 + compileSdkVersion 31 if (project.hasProperty("ANDROID_NDK_VERSION")) { ndkVersion project.property("ANDROID_NDK_VERSION") } @@ -166,7 +166,7 @@ android { defaultConfig { applicationId "com.facebook.react.uiapp" minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 31 versionCode 1 versionName "1.0" testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type diff --git a/packages/rn-tester/android/app/src/main/AndroidManifest.xml b/packages/rn-tester/android/app/src/main/AndroidManifest.xml index 8ee8ae3a352256..f50034f92519f8 100644 --- a/packages/rn-tester/android/app/src/main/AndroidManifest.xml +++ b/packages/rn-tester/android/app/src/main/AndroidManifest.xml @@ -36,7 +36,8 @@ android:label="@string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" - android:configChanges="orientation|screenSize|uiMode" > + android:configChanges="orientation|screenSize|uiMode" + android:exported="true"> @@ -51,7 +52,7 @@ - + - + diff --git a/template/android/app/src/main/AndroidManifest.xml b/template/android/app/src/main/AndroidManifest.xml index 9ec74db36bf5e3..7ba57ca1dc0587 100644 --- a/template/android/app/src/main/AndroidManifest.xml +++ b/template/android/app/src/main/AndroidManifest.xml @@ -15,7 +15,8 @@ android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode" android:launchMode="singleTask" - android:windowSoftInputMode="adjustResize"> + android:windowSoftInputMode="adjustResize" + android:exported="true"> diff --git a/template/android/build.gradle b/template/android/build.gradle index 3be1031fb223dd..bf07f1ccf051e2 100644 --- a/template/android/build.gradle +++ b/template/android/build.gradle @@ -2,10 +2,10 @@ buildscript { ext { - buildToolsVersion = "30.0.2" + buildToolsVersion = "31.0.0" minSdkVersion = 21 - compileSdkVersion = 30 - targetSdkVersion = 30 + compileSdkVersion = 31 + targetSdkVersion = 31 ndkVersion = "21.4.7075529" } repositories {