From 11aba3ab34ca844c314759eee9dabf29e8375db9 Mon Sep 17 00:00:00 2001 From: "Mr. 17" Date: Sun, 29 Dec 2024 10:51:52 +0530 Subject: [PATCH] Fix #5535: Upgrade builds to target SDK 34 (#5604) ## Explanation Fixes #5535 This PR updates all build and target SDKs for both Gradle and Bazel builds to SDK 34 to comply with the latest Play Store requirements. The key considerations for this upgrade include: - **Font Scaling**: SDK 34 introduces support for font scaling up to 200% #5607. - **`scaledDensity` Deprecation**: The scaledDensity property in the DisplayMetrics class is now deprecated #5625. Details about SDK 34 changes, potential issues, and mitigations can be found in the #5535 issue thread. ## Essential Checklist - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only If your PR includes UI-related changes, then: - Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes - For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see [RTL guide](https://github.com/oppia/oppia-android/wiki/RTL-Guidelines)) - Add a video showing the full UX flow with a screen reader enabled (see [accessibility guide](https://github.com/oppia/oppia-android/wiki/Accessibility-A11y-Guide)) - For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included - Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing --------- Co-authored-by: Ben Henning --- .../action.yml | 4 ++-- BUILD.bazel | 4 ++-- app/build.gradle | 6 +++--- app/src/main/AppAndroidManifest.xml | 2 +- app/src/main/DatabindingAdaptersManifest.xml | 2 +- app/src/main/DatabindingResourcesManifest.xml | 2 +- app/src/main/RecyclerviewAdaptersManifest.xml | 2 +- app/src/main/ViewModelManifest.xml | 2 +- app/src/main/ViewModelsManifest.xml | 2 +- app/src/main/ViewsManifest.xml | 2 +- .../app/utility/FontScaleConfigurationUtil.kt | 2 ++ app/src/test/resources/robolectric.properties | 2 +- build_flavors.bzl | 12 ++++++------ build_vars.bzl | 2 +- .../org/oppia/android/config/AndroidManifest.xml | 2 +- data/build.gradle | 6 +++--- domain/build.gradle | 6 +++--- domain/src/main/AndroidManifest.xml | 2 +- domain/src/test/resources/robolectric.properties | 2 +- .../scripts/common/AndroidBuildSdkPropertiesTest.kt | 2 +- testing/build.gradle | 6 +++--- testing/src/test/resources/robolectric.properties | 2 +- utility/build.gradle | 6 +++--- utility/src/main/AndroidManifest.xml | 2 +- 24 files changed, 42 insertions(+), 40 deletions(-) diff --git a/.github/actions/set-up-android-bazel-build-environment/action.yml b/.github/actions/set-up-android-bazel-build-environment/action.yml index fc24770010a..499b78ab61b 100644 --- a/.github/actions/set-up-android-bazel-build-environment/action.yml +++ b/.github/actions/set-up-android-bazel-build-environment/action.yml @@ -72,9 +72,9 @@ runs: $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platform-tools" shell: bash - - name: Install SDK 33 + - name: Install SDK 34 run: | - $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-33" + $ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-34" shell: bash - name: Install build tools 32.0.0 diff --git a/BUILD.bazel b/BUILD.bazel index f0db399e20c..4c6d5a97c2a 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -119,14 +119,14 @@ package_group( "flavor": "oppia", "min_sdk_version": 21, "multidex": "native", - "target_sdk_version": 33, + "target_sdk_version": 34, }, { "flavor": "oppia_kitkat", "main_dex_list": "//:config/kitkat_main_dex_class_list.txt", "min_sdk_version": 21, "multidex": "manual_main_dex", - "target_sdk_version": 33, + "target_sdk_version": 34, }, ] ] diff --git a/app/build.gradle b/app/build.gradle index 7c94678f75c..bc5d6d4b15a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,12 +5,12 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 33 - buildToolsVersion "30.0.2" + compileSdkVersion 34 + buildToolsVersion "30.0.0" defaultConfig { applicationId "org.oppia.android" minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName "1.0" multiDexEnabled true diff --git a/app/src/main/AppAndroidManifest.xml b/app/src/main/AppAndroidManifest.xml index 211884a0158..0b5a672e4b7 100644 --- a/app/src/main/AppAndroidManifest.xml +++ b/app/src/main/AppAndroidManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="34" /> diff --git a/app/src/main/DatabindingAdaptersManifest.xml b/app/src/main/DatabindingAdaptersManifest.xml index d3e60f6d5f4..783be2f9363 100644 --- a/app/src/main/DatabindingAdaptersManifest.xml +++ b/app/src/main/DatabindingAdaptersManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="34" /> diff --git a/app/src/main/DatabindingResourcesManifest.xml b/app/src/main/DatabindingResourcesManifest.xml index c9f98dbf248..b48bc109de3 100644 --- a/app/src/main/DatabindingResourcesManifest.xml +++ b/app/src/main/DatabindingResourcesManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="34" /> diff --git a/app/src/main/RecyclerviewAdaptersManifest.xml b/app/src/main/RecyclerviewAdaptersManifest.xml index 6585b5ea24c..8f917756650 100644 --- a/app/src/main/RecyclerviewAdaptersManifest.xml +++ b/app/src/main/RecyclerviewAdaptersManifest.xml @@ -1,5 +1,5 @@ + android:targetSdkVersion="34" /> diff --git a/app/src/main/ViewModelManifest.xml b/app/src/main/ViewModelManifest.xml index c6c3e62e26b..67e79d1f41d 100644 --- a/app/src/main/ViewModelManifest.xml +++ b/app/src/main/ViewModelManifest.xml @@ -3,5 +3,5 @@ + android:targetSdkVersion="34" /> diff --git a/app/src/main/ViewModelsManifest.xml b/app/src/main/ViewModelsManifest.xml index e210893ecd0..83d6b023161 100644 --- a/app/src/main/ViewModelsManifest.xml +++ b/app/src/main/ViewModelsManifest.xml @@ -3,5 +3,5 @@ + android:targetSdkVersion="34" /> diff --git a/app/src/main/ViewsManifest.xml b/app/src/main/ViewsManifest.xml index b77df4edb19..eac7e6941c4 100644 --- a/app/src/main/ViewsManifest.xml +++ b/app/src/main/ViewsManifest.xml @@ -3,5 +3,5 @@ + android:targetSdkVersion="34" /> diff --git a/app/src/main/java/org/oppia/android/app/utility/FontScaleConfigurationUtil.kt b/app/src/main/java/org/oppia/android/app/utility/FontScaleConfigurationUtil.kt index 80603b9fb95..6570499f35b 100644 --- a/app/src/main/java/org/oppia/android/app/utility/FontScaleConfigurationUtil.kt +++ b/app/src/main/java/org/oppia/android/app/utility/FontScaleConfigurationUtil.kt @@ -21,6 +21,8 @@ class FontScaleConfigurationUtil @Inject constructor() { // TODO(#3616): Migrate to the proper SDK 30+ APIs. @Suppress("DEPRECATION") // The code is correct for targeted versions of Android. windowManager!!.defaultDisplay.getMetrics(metrics) + // TODO(#5625): Migrate away from scaledDensity. + @Suppress("DEPRECATION") metrics.scaledDensity = configuration.fontScale * metrics.density context.createConfigurationContext(configuration) context.resources.displayMetrics.setTo(metrics) diff --git a/app/src/test/resources/robolectric.properties b/app/src/test/resources/robolectric.properties index 1aafcf8ea7d..1a1a2f7bdd6 100644 --- a/app/src/test/resources/robolectric.properties +++ b/app/src/test/resources/robolectric.properties @@ -1,3 +1,3 @@ # app/src/test/resources/robolectric.properties -# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 33 +# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 34 sdk=30 diff --git a/build_flavors.bzl b/build_flavors.bzl index d9d6af2bf96..aa5493a391e 100644 --- a/build_flavors.bzl +++ b/build_flavors.bzl @@ -44,7 +44,7 @@ _FLAVOR_METADATA = { "dev": { "manifest": "//app:src/main/AndroidManifest.xml", "min_sdk_version": 21, - "target_sdk_version": 33, + "target_sdk_version": 34, "multidex": "native", "proguard_specs": [], # Developer builds are not optimized. "production_release": False, @@ -58,7 +58,7 @@ _FLAVOR_METADATA = { "dev_kitkat": { "manifest": "//app:src/main/AndroidManifest.xml", "min_sdk_version": 21, - "target_sdk_version": 33, + "target_sdk_version": 34, "multidex": "manual_main_dex", "main_dex_list": _MAIN_DEX_LIST_TARGET_KITKAT, "proguard_specs": [], # Developer builds are not optimized. @@ -73,7 +73,7 @@ _FLAVOR_METADATA = { "alpha": { "manifest": "//app:src/main/AndroidManifest.xml", "min_sdk_version": 21, - "target_sdk_version": 33, + "target_sdk_version": 34, "multidex": "native", "proguard_specs": _PRODUCTION_PROGUARD_SPECS, "production_release": True, @@ -87,7 +87,7 @@ _FLAVOR_METADATA = { "alpha_kitkat": { "manifest": "//app:src/main/AndroidManifest.xml", "min_sdk_version": 21, - "target_sdk_version": 33, + "target_sdk_version": 34, "multidex": "manual_main_dex", "main_dex_list": _MAIN_DEX_LIST_TARGET_KITKAT, "proguard_specs": [], @@ -102,7 +102,7 @@ _FLAVOR_METADATA = { "beta": { "manifest": "//app:src/main/AndroidManifest.xml", "min_sdk_version": 21, - "target_sdk_version": 33, + "target_sdk_version": 34, "multidex": "native", "proguard_specs": _PRODUCTION_PROGUARD_SPECS, "production_release": True, @@ -116,7 +116,7 @@ _FLAVOR_METADATA = { "ga": { "manifest": "//app:src/main/AndroidManifest.xml", "min_sdk_version": 21, - "target_sdk_version": 33, + "target_sdk_version": 34, "multidex": "native", "proguard_specs": _PRODUCTION_PROGUARD_SPECS, "production_release": True, diff --git a/build_vars.bzl b/build_vars.bzl index 6fd23a4f9a5..be9b7e6460b 100644 --- a/build_vars.bzl +++ b/build_vars.bzl @@ -1,2 +1,2 @@ -BUILD_SDK_VERSION = 33 +BUILD_SDK_VERSION = 34 BUILD_TOOLS_VERSION = "32.0.0" diff --git a/config/src/java/org/oppia/android/config/AndroidManifest.xml b/config/src/java/org/oppia/android/config/AndroidManifest.xml index 123ff9bc501..58158ec68c4 100644 --- a/config/src/java/org/oppia/android/config/AndroidManifest.xml +++ b/config/src/java/org/oppia/android/config/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/data/build.gradle b/data/build.gradle index daadba86bb8..3d93aa36af8 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 33 - buildToolsVersion "30.0.2" + compileSdkVersion 34 + buildToolsVersion "30.0.0" defaultConfig { minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/domain/build.gradle b/domain/build.gradle index 5634edfa80f..efec77bb8d3 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 33 - buildToolsVersion "30.0.2" + compileSdkVersion 34 + buildToolsVersion "30.0.0" defaultConfig { minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName "1.0" javaCompileOptions { diff --git a/domain/src/main/AndroidManifest.xml b/domain/src/main/AndroidManifest.xml index ea5a0a7a495..d0224a336c7 100644 --- a/domain/src/main/AndroidManifest.xml +++ b/domain/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/domain/src/test/resources/robolectric.properties b/domain/src/test/resources/robolectric.properties index cedb3da0a90..ea76247318e 100644 --- a/domain/src/test/resources/robolectric.properties +++ b/domain/src/test/resources/robolectric.properties @@ -1,3 +1,3 @@ # domain/src/test/resources/robolectric.properties -# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 33 +# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 34 sdk=30 diff --git a/scripts/src/javatests/org/oppia/android/scripts/common/AndroidBuildSdkPropertiesTest.kt b/scripts/src/javatests/org/oppia/android/scripts/common/AndroidBuildSdkPropertiesTest.kt index be621bd982c..8014d51ffd8 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/common/AndroidBuildSdkPropertiesTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/common/AndroidBuildSdkPropertiesTest.kt @@ -19,7 +19,7 @@ class AndroidBuildSdkPropertiesTest { fun testBuildSdkVersion_isTheCorrectSdkVersion() { val properties = AndroidBuildSdkProperties() - assertThat(properties.buildSdkVersion).isEqualTo(33) + assertThat(properties.buildSdkVersion).isEqualTo(34) } @Test diff --git a/testing/build.gradle b/testing/build.gradle index 94f2e559dff..ae6d8acae0a 100644 --- a/testing/build.gradle +++ b/testing/build.gradle @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 33 - buildToolsVersion "30.0.2" + compileSdkVersion 34 + buildToolsVersion "30.0.0" defaultConfig { minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName "1.0" } diff --git a/testing/src/test/resources/robolectric.properties b/testing/src/test/resources/robolectric.properties index 12d726938f8..69090e67ba2 100644 --- a/testing/src/test/resources/robolectric.properties +++ b/testing/src/test/resources/robolectric.properties @@ -1,3 +1,3 @@ # testing/src/test/resources/robolectric.properties -# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 33 +# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 34 sdk=30 diff --git a/utility/build.gradle b/utility/build.gradle index 53e7905913f..b6949ef736c 100644 --- a/utility/build.gradle +++ b/utility/build.gradle @@ -3,12 +3,12 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { - compileSdkVersion 33 - buildToolsVersion "30.0.2" + compileSdkVersion 34 + buildToolsVersion "30.0.0" defaultConfig { minSdkVersion 21 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 1 versionName "1.0" javaCompileOptions { diff --git a/utility/src/main/AndroidManifest.xml b/utility/src/main/AndroidManifest.xml index d06626d50ac..3064e8c1564 100644 --- a/utility/src/main/AndroidManifest.xml +++ b/utility/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - +