Skip to content

Commit 1181ca2

Browse files
authored
Fix #5137: Upgrade builds to target SDK 33 (#5222)
## Explanation Fixes #5137 Partially mitigates #5233 This updates all build & target SDKs for Gradle & Bazel builds to now target SDK 33, per the new Play Store mandate (see https://support.google.com/googleplay/android-developer/answer/11926878?hl=en). The analysis of SDK 33 features, potential issues, and potential mitigations are described in #5137. It was determined that there are no obvious code changes needed beyond the minimum to target SDK 33. We'll be relying on some platform-level regression testing plus the Play Console's pre-submit app analysis report for finalizing the go/no-go decision for SDK 33 support. Testing consisted of manually playing through the app and seeing if there were any issues using emulators both with SDK 33 and lower versions. #5137 documents the issues found and their ultimate causes. Since no functionality changes were needed for SDK 33, no tests needed updating. Separately, tests are still running on SDK 30 due to being stuck (see #4748). One issue unrelated to SDK 33 was observed: when playing through the prototype lesson, I once again brought the app into a broken state wherein I couldn't leave the lesson via navigation. We've hit this issue a few times, but still don't know the root cause. #5233 was filed and a mitigation was introduced in this PR (+ a test for it): if the exploration player observes a failure when trying to stop the player session (for whatever reason), it still proceeds with its "end of activity" flow (e.g. finishing the activity). This provides at least an escape hatch for users who somehow hit this state. Note that this isn't a proper fix for #5233 given the lack of a known root cause, so this is only considered a mitigation. The new test was verified as failing if the mitigation is omitted: ![image](https://github.com/oppia/oppia-android/assets/12983742/10ddbf85-332c-4469-8efa-483a967170f9) Note that ``ExplorationActivityTest``'s setup was tweaked to change the parent screen since this affects back navigation routing. I opted to using lessons tab as the parent screen since it's the most common route for users to hit, so it makes sense for our tests to default to that if they don't specifically need to use a different route (and none of the existing tests seemed to have an issue with this change). ## 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 N/A -- This isn't changing any UIs directly, and per the analysis in #5137 it doesn't seem that there are any relevant new UIs enabled in SDK 33 that would affect Oppia.
1 parent 6fec2e2 commit 1181ca2

File tree

27 files changed

+90
-56
lines changed

27 files changed

+90
-56
lines changed

.github/actions/set-up-android-bazel-build-environment/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ runs:
7272
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platform-tools"
7373
shell: bash
7474

75-
- name: Install SDK 31
75+
- name: Install SDK 33
7676
run: |
77-
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-31"
77+
$ANDROID_HOME/cmdline-tools/tools/bin/sdkmanager --install "platforms;android-33"
7878
shell: bash
7979

8080
- name: Install build tools 29.0.2

BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ package_group(
118118
"flavor": "oppia",
119119
"min_sdk_version": 21,
120120
"multidex": "native",
121-
"target_sdk_version": 31,
121+
"target_sdk_version": 33,
122122
},
123123
{
124124
"flavor": "oppia_kitkat",
125125
"main_dex_list": "//:config/kitkat_main_dex_class_list.txt",
126126
"min_sdk_version": 19,
127127
"multidex": "manual_main_dex",
128-
"target_sdk_version": 31,
128+
"target_sdk_version": 33,
129129
},
130130
]
131131
]

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ load("//third_party:versions.bzl", "HTTP_DEPENDENCY_VERSIONS", "get_maven_depend
1111
# TODO(#1542): Sync Android SDK version with the manifest.
1212
android_sdk_repository(
1313
name = "androidsdk",
14-
api_level = 31,
14+
api_level = 33,
1515
build_tools_version = "29.0.2",
1616
)
1717

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ apply plugin: 'kotlin-android-extensions'
66
apply plugin: 'kotlin-kapt'
77

88
android {
9-
compileSdkVersion 31
9+
compileSdkVersion 33
1010
buildToolsVersion "29.0.2"
1111
defaultConfig {
1212
applicationId "org.oppia.android"
1313
minSdkVersion 19
14-
targetSdkVersion 31
14+
targetSdkVersion 33
1515
versionCode 1
1616
versionName "1.0"
1717
multiDexEnabled true

app/src/main/AppAndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="org.oppia.android.app.ui">
33
<uses-sdk android:minSdkVersion="19"
4-
android:targetSdkVersion="31" />
4+
android:targetSdkVersion="33" />
55
</manifest>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="org.oppia.android.databinding.adapters">
33
<uses-sdk android:minSdkVersion="19"
4-
android:targetSdkVersion="31" />
4+
android:targetSdkVersion="33" />
55
</manifest>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="org.oppia.android.app.databinding">
33
<uses-sdk android:minSdkVersion="19"
4-
android:targetSdkVersion="31" />
4+
android:targetSdkVersion="33" />
55
</manifest>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="org.oppia.android.app.recyclerview.adapters">
33
<uses-sdk android:minSdkVersion="19"
4-
android:targetSdkVersion="31" />
4+
android:targetSdkVersion="33" />
55
</manifest>

app/src/main/ViewModelManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
44
package="org.oppia.android.app.vm">
55
<uses-sdk android:minSdkVersion="19"
6-
android:targetSdkVersion="31" />
6+
android:targetSdkVersion="33" />
77
</manifest>

app/src/main/ViewModelsManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
44
package="org.oppia.android.app.view.models">
55
<uses-sdk android:minSdkVersion="19"
6-
android:targetSdkVersion="31" />
6+
android:targetSdkVersion="33" />
77
</manifest>

app/src/main/ViewsManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
44
package="org.oppia.android.app.views">
55
<uses-sdk android:minSdkVersion="19"
6-
android:targetSdkVersion="31" />
6+
android:targetSdkVersion="33" />
77
</manifest>

app/src/main/java/org/oppia/android/app/player/exploration/ExplorationActivityPresenter.kt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -286,25 +286,25 @@ class ExplorationActivityPresenter @Inject constructor(
286286

287287
fun stopExploration(isCompletion: Boolean) {
288288
fontScaleConfigurationUtil.adjustFontScale(activity, ReadingTextSize.MEDIUM_TEXT_SIZE)
289-
explorationDataController.stopPlayingExploration(isCompletion).toLiveData()
290-
.observe(
291-
activity,
292-
{
293-
when (it) {
294-
is AsyncResult.Pending -> oppiaLogger.d("ExplorationActivity", "Stopping exploration")
295-
is AsyncResult.Failure ->
296-
oppiaLogger.e("ExplorationActivity", "Failed to stop exploration", it.error)
297-
is AsyncResult.Success -> {
298-
oppiaLogger.d("ExplorationActivity", "Successfully stopped exploration")
299-
if (isCompletion) {
300-
maybeShowSurveyDialog(profileId, topicId)
301-
} else {
302-
backPressActivitySelector()
303-
}
304-
}
289+
explorationDataController.stopPlayingExploration(isCompletion).toLiveData().observe(activity) {
290+
when (it) {
291+
is AsyncResult.Pending ->
292+
oppiaLogger.d("ExplorationActivity", "Stopping exploration")
293+
is AsyncResult.Failure -> {
294+
oppiaLogger.e("ExplorationActivity", "Failed to stop exploration", it.error)
295+
// Allow the user to always exit if they get into a broken state.
296+
backPressActivitySelector()
297+
}
298+
is AsyncResult.Success -> {
299+
oppiaLogger.d("ExplorationActivity", "Successfully stopped exploration")
300+
if (isCompletion) {
301+
maybeShowSurveyDialog(profileId, topicId)
302+
} else {
303+
backPressActivitySelector()
305304
}
306305
}
307-
)
306+
}
307+
}
308308
}
309309

310310
fun onKeyboardAction(actionCode: Int) {

app/src/sharedTest/java/org/oppia/android/app/player/exploration/ExplorationActivityTest.kt

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,38 @@ class ExplorationActivityTest {
18971897
explorationDataController.stopPlayingExploration(isCompletion = false)
18981898
}
18991899

1900+
@Test
1901+
fun testExpActivity_pressBack_whenProgressControllerBroken_stillEndsActivity() {
1902+
setUpAudioForFractionLesson()
1903+
explorationActivityTestRule.launchActivity(
1904+
createExplorationActivityIntent(
1905+
internalProfileId,
1906+
FRACTIONS_TOPIC_ID,
1907+
FRACTIONS_STORY_ID_0,
1908+
FRACTIONS_EXPLORATION_ID_0,
1909+
shouldSavePartialProgress = true
1910+
)
1911+
)
1912+
explorationDataController.startPlayingNewExploration(
1913+
internalProfileId,
1914+
FRACTIONS_TOPIC_ID,
1915+
FRACTIONS_STORY_ID_0,
1916+
FRACTIONS_EXPLORATION_ID_0
1917+
)
1918+
testCoroutineDispatchers.runCurrent()
1919+
1920+
// Simulate cases when the data controller enters a bad state by pre-finishing the exploration
1921+
// prior to trying to exit. While this seems impossible, it's been observed in real situations
1922+
// without a known cause. If it does happen, the user needs to have an escape hatch to actually
1923+
// leave. See #5233.
1924+
explorationDataController.stopPlayingExploration(isCompletion = false)
1925+
testCoroutineDispatchers.runCurrent()
1926+
pressBack()
1927+
testCoroutineDispatchers.runCurrent()
1928+
1929+
assertThat(explorationActivityTestRule.activity.isFinishing).isTrue()
1930+
}
1931+
19001932
@Test
19011933
@RunOn(TestPlatform.ROBOLECTRIC) // TODO(#3858): Enable for Espresso.
19021934
fun testExpActivity_englishContentLang_contentIsInEnglish() {
@@ -2303,13 +2335,15 @@ class ExplorationActivityTest {
23032335
explorationId: String,
23042336
shouldSavePartialProgress: Boolean
23052337
): Intent {
2338+
// Note that the parent screen is defaulted to TOPIC_SCREEN_LESSONS_TAB since that's the most
2339+
// typical route to playing an exploration.
23062340
return ExplorationActivity.createExplorationActivityIntent(
23072341
ApplicationProvider.getApplicationContext(),
23082342
ProfileId.newBuilder().apply { internalId = internalProfileId }.build(),
23092343
topicId,
23102344
storyId,
23112345
explorationId,
2312-
parentScreen = ExplorationActivityParams.ParentScreen.PARENT_SCREEN_UNSPECIFIED,
2346+
parentScreen = ExplorationActivityParams.ParentScreen.TOPIC_SCREEN_LESSONS_TAB,
23132347
shouldSavePartialProgress
23142348
)
23152349
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# app/src/test/resources/robolectric.properties
2-
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 31
2+
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 33
33
sdk=30

build_flavors.bzl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ _FLAVOR_METADATA = {
4646
"dev": {
4747
"manifest": "//app:src/main/AndroidManifest.xml",
4848
"min_sdk_version": 21,
49-
"target_sdk_version": 31,
49+
"target_sdk_version": 33,
5050
"multidex": "native",
5151
"proguard_specs": [], # Developer builds are not optimized.
5252
"production_release": False,
@@ -60,7 +60,7 @@ _FLAVOR_METADATA = {
6060
"dev_kitkat": {
6161
"manifest": "//app:src/main/AndroidManifest.xml",
6262
"min_sdk_version": 19,
63-
"target_sdk_version": 31,
63+
"target_sdk_version": 33,
6464
"multidex": "manual_main_dex",
6565
"main_dex_list": _MAIN_DEX_LIST_TARGET_KITKAT,
6666
"proguard_specs": [], # Developer builds are not optimized.
@@ -75,7 +75,7 @@ _FLAVOR_METADATA = {
7575
"alpha": {
7676
"manifest": "//app:src/main/AndroidManifest.xml",
7777
"min_sdk_version": 21,
78-
"target_sdk_version": 31,
78+
"target_sdk_version": 33,
7979
"multidex": "native",
8080
"proguard_specs": _PRODUCTION_PROGUARD_SPECS,
8181
"production_release": True,
@@ -89,7 +89,7 @@ _FLAVOR_METADATA = {
8989
"alpha_kitkat": {
9090
"manifest": "//app:src/main/AndroidManifest.xml",
9191
"min_sdk_version": 19,
92-
"target_sdk_version": 31,
92+
"target_sdk_version": 33,
9393
"multidex": "manual_main_dex",
9494
"main_dex_list": _MAIN_DEX_LIST_TARGET_KITKAT,
9595
"proguard_specs": [],
@@ -104,7 +104,7 @@ _FLAVOR_METADATA = {
104104
"alpha_kenya": {
105105
"manifest": "//app:src/main/AndroidManifest.xml",
106106
"min_sdk_version": 21,
107-
"target_sdk_version": 31,
107+
"target_sdk_version": 33,
108108
"multidex": "native",
109109
"proguard_specs": _PRODUCTION_PROGUARD_SPECS,
110110
"production_release": True,
@@ -118,7 +118,7 @@ _FLAVOR_METADATA = {
118118
"beta": {
119119
"manifest": "//app:src/main/AndroidManifest.xml",
120120
"min_sdk_version": 21,
121-
"target_sdk_version": 31,
121+
"target_sdk_version": 33,
122122
"multidex": "native",
123123
"proguard_specs": _PRODUCTION_PROGUARD_SPECS,
124124
"production_release": True,
@@ -132,7 +132,7 @@ _FLAVOR_METADATA = {
132132
"ga": {
133133
"manifest": "//app:src/main/AndroidManifest.xml",
134134
"min_sdk_version": 21,
135-
"target_sdk_version": 31,
135+
"target_sdk_version": 33,
136136
"multidex": "native",
137137
"proguard_specs": _PRODUCTION_PROGUARD_SPECS,
138138
"production_release": True,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="org.oppia.android.config">
33

4-
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="31" />
4+
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="33" />
55
</manifest>

data/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ apply plugin: 'kotlin-android-extensions'
44
apply plugin: 'kotlin-kapt'
55

66
android {
7-
compileSdkVersion 31
7+
compileSdkVersion 33
88
buildToolsVersion "29.0.2"
99

1010
defaultConfig {
1111
minSdkVersion 19
12-
targetSdkVersion 31
12+
targetSdkVersion 33
1313
versionCode 1
1414
versionName "1.0"
1515
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# data/src/test/resources/robolectric.properties
2-
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 31
2+
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 33
33
sdk=30

domain/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ apply plugin: 'kotlin-android-extensions'
44
apply plugin: 'kotlin-kapt'
55

66
android {
7-
compileSdkVersion 31
7+
compileSdkVersion 33
88
buildToolsVersion "29.0.2"
99

1010
defaultConfig {
1111
minSdkVersion 19
12-
targetSdkVersion 31
12+
targetSdkVersion 33
1313
versionCode 1
1414
versionName "1.0"
1515
javaCompileOptions {

domain/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="org.oppia.android.domain">
4-
<uses-sdk android:targetSdkVersion="31" />
4+
<uses-sdk android:targetSdkVersion="33" />
55
</manifest>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# domain/src/test/resources/robolectric.properties
2-
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 31
2+
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 33
33
sdk=30

instrumentation/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ android_binary(
1818
manifest_values = {
1919
"applicationId": "org.oppia.android",
2020
"minSdkVersion": "19",
21-
"targetSdkVersion": "31",
21+
"targetSdkVersion": "33",
2222
"versionCode": "0",
2323
"versionName": "0.1-test",
2424
},

testing/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ apply plugin: 'kotlin-android-extensions'
44
apply plugin: 'kotlin-kapt'
55

66
android {
7-
compileSdkVersion 31
7+
compileSdkVersion 33
88
buildToolsVersion "29.0.2"
99

1010
defaultConfig {
1111
minSdkVersion 19
12-
targetSdkVersion 31
12+
targetSdkVersion 33
1313
versionCode 1
1414
versionName "1.0"
1515
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# testing/src/test/resources/robolectric.properties
2-
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 31
2+
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 33
33
sdk=30

utility/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ apply plugin: 'kotlin-android-extensions'
44
apply plugin: 'kotlin-kapt'
55

66
android {
7-
compileSdkVersion 31
7+
compileSdkVersion 33
88
buildToolsVersion "29.0.2"
99

1010
defaultConfig {
1111
minSdkVersion 19
12-
targetSdkVersion 31
12+
targetSdkVersion 33
1313
versionCode 1
1414
versionName "1.0"
1515
javaCompileOptions {

utility/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="org.oppia.android.util">
3-
<uses-sdk android:targetSdkVersion="31" />
3+
<uses-sdk android:targetSdkVersion="33" />
44
</manifest>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# utility/src/test/resources/robolectric.properties
2-
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 31
2+
# TODO(#4748): Remove the need for this file after upgrading Robolectric tests to API 33
33
sdk=30

0 commit comments

Comments
 (0)