Skip to content

Commit

Permalink
Fix #5535: Upgrade builds to target SDK 34 (#5604)
Browse files Browse the repository at this point in the history
<!-- READ ME FIRST: Please fill in the explanation section below and
check off every point from the Essential Checklist! -->
## Explanation
<!--
- Explain what your PR does. If this PR fixes an existing bug, please
include
- "Fixes #bugnum:" in the explanation so that GitHub can auto-close the
issue
  - when this PR is merged.
  -->
  
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
<!-- Please tick the relevant boxes by putting an "x" in them. -->
- [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
<!-- Delete these section if this PR does not include UI-related
changes. -->
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 <[email protected]>
  • Loading branch information
theMr17 and BenHenning authored Dec 29, 2024
1 parent f6da943 commit 11aba3a
Show file tree
Hide file tree
Showing 24 changed files with 42 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
]
]
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AppAndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.ui">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/DatabindingAdaptersManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.databinding.adapters">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/DatabindingResourcesManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.databinding">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/RecyclerviewAdaptersManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.recyclerview.adapters">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.vm">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewModelsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.view.models">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion app/src/main/ViewsManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.app.views">
<uses-sdk android:minSdkVersion="19"
android:targetSdkVersion="33" />
android:targetSdkVersion="34" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions build_flavors.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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,
Expand All @@ -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": [],
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion build_vars.bzl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BUILD_SDK_VERSION = 33
BUILD_SDK_VERSION = 34
BUILD_TOOLS_VERSION = "32.0.0"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.config">

<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="33" />
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="34" />
</manifest>
6 changes: 3 additions & 3 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions domain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion domain/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.domain">
<uses-sdk android:targetSdkVersion="33" />
<uses-sdk android:targetSdkVersion="34" />
</manifest>
2 changes: 1 addition & 1 deletion domain/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AndroidBuildSdkPropertiesTest {
fun testBuildSdkVersion_isTheCorrectSdkVersion() {
val properties = AndroidBuildSdkProperties()

assertThat(properties.buildSdkVersion).isEqualTo(33)
assertThat(properties.buildSdkVersion).isEqualTo(34)
}

@Test
Expand Down
6 changes: 3 additions & 3 deletions testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion testing/src/test/resources/robolectric.properties
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions utility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion utility/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.oppia.android.util">
<uses-sdk android:targetSdkVersion="33" />
<uses-sdk android:targetSdkVersion="34" />
</manifest>

0 comments on commit 11aba3a

Please sign in to comment.