Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4746: Update app to target SDK 31 #4747

Merged
merged 5 commits into from
Nov 19, 2022
Merged

Conversation

BenHenning
Copy link
Sponsor Member

@BenHenning BenHenning commented Nov 18, 2022

Explanation

Fixes #4746

This PR updates the app to target SDK 31 instead of 30 as this is now required for continued Play Store releases.

Verification from the PR standpoint heavily relies on CI checks passing. Beyond that, manual testing is needed to ensure no Android behavior changes have led to regressions or new breakages.

This PR does NOT include updating Robolectric tests to run on SDK 31 since it's actually much harder than I had expected, and would lead to potential production-affecting changes (as it would require updating Kotlin & potentially other dependencies). #4748 is tracking fixing this in the long-term.

Essential Checklist

  • 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: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

For UI-specific PRs only

N/A, mostly. While this is an infrastructure change, Android component behaviors change with different target SDKs so it's quite possible for there to be UI regressions or issues. Fortunately, most of the UI used by the app is material and Jetpack (meaning it ships with the app and will be mostly unaffected by target SDK changes).

Properly moving tests over will be fixed with #4748.
The configurations for these were incorrect before--they should have
been using target SDK version, not max.
@BenHenning BenHenning marked this pull request as ready for review November 19, 2022 05:07
@BenHenning
Copy link
Sponsor Member Author

PTAL @seanlip. I'm pretty sure CI will pass at this point.

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just had one question.

testing/src/test/AndroidManifest.xml Show resolved Hide resolved
@seanlip seanlip assigned BenHenning and unassigned seanlip Nov 19, 2022
@oppiabot oppiabot bot added the PR: LGTM label Nov 19, 2022
@oppiabot
Copy link

oppiabot bot commented Nov 19, 2022

Hi @BenHenning, this PR is ready to be merged. Please address any remaining comments prior to merging, and feel free to merge this PR once the CI checks pass and you're happy with it. Thanks!

@BenHenning
Copy link
Sponsor Member Author

Thanks @seanlip! Resolving your conversation thread since it didn't request any changes & you already approved the PR (but please reach out if you have follow-up concerns; happy to address them in a subsequent PR).

@BenHenning
Copy link
Sponsor Member Author

Merging since there's no other outstanding work here.

@BenHenning BenHenning merged commit 7cb38ff into develop Nov 19, 2022
@BenHenning BenHenning deleted the update-to-target-sdk-31 branch November 19, 2022 05:31
BenHenning added a commit that referenced this pull request Nov 19, 2022
## Explanation
Fixes #4746

This PR updates the app to target SDK 31 instead of 30 as this is now
required for continued Play Store releases.

Verification from the PR standpoint heavily relies on CI checks passing.
Beyond that, manual testing is needed to ensure no Android behavior
changes have led to regressions or new breakages.

This PR does NOT include updating Robolectric tests to run on SDK 31
since it's actually much harder than I had expected, and would lead to
potential production-affecting changes (as it would require updating
Kotlin & potentially other dependencies). #4748 is tracking fixing this
in the long-term.

## 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, mostly. While this is an infrastructure change, Android component
behaviors change with different target SDKs so it's quite possible for
there to be UI regressions or issues. Fortunately, most of the UI used
by the app is material and Jetpack (meaning it ships with the app and
will be mostly unaffected by target SDK changes).
@BenHenning BenHenning added PR: Cherrypick requested Indicates that a PR is being requested for being cherrypicked into the ongoing release branch. PR: Cherrypick completed Indicates a cherrypick request was approved & completed for a PR. labels Nov 19, 2022
JishnuGoyal added a commit to JishnuGoyal/oppia-android that referenced this pull request Nov 20, 2022
BenHenning added a commit to BenHenning/oppia-android that referenced this pull request Nov 21, 2022
@BenHenning BenHenning mentioned this pull request Nov 21, 2022
6 tasks
BenHenning added a commit that referenced this pull request Nov 23, 2022
## Explanation
Fixes #4750

This PR fixes issues that were introduced in #4747 when trying to use
the app on an actual API 31 device. The problems come from two breaking
changes in Android 12:
- Public activities, services, and providers must be marked as exported
(this only affected our SplashActivity).
- PendingIntents must be explicitly marked as mutable/immutable (this
only affects WorkManager, but that's tricky for us).

The WorkManager issue was fixed in version 2.7.0 (where we currently
depend on version 2.4.0), but we can't actually updated in a way that
would be low-risk to cherry-pick (since it would require updating our
Kotlin SDK to 1.5.x instead of 1.4.x). A safer option is to disable
WorkManager outright, but while doing this I discovered that we have
unrestricted getInstance() calls that will force WorkManager to get
created regardless. This was fixed by introducing a new
analytics-specific application creation listener and ensuring those do
not get called for SDK 31+. #4751 is tracking fixing this longer term.
Approximately 9% of our users will have analytics disabled until we
properly fix it & push a new release.

Note that I opted for a fix-forward instead of rolling back #4747 since
these are small PRs that need to be easily cherry-picked, and it's
guaranteed that the target SDK change be isolated to SDK 31 devices (so
developers would still be able to use the app on lower versions).

Proper testing for ensuring this works requires manual testing, for now
(as we don't have automated end-to-end tests). I manually verified that
the app opens and can be used on Android 12. One test exemption was
added for the new listener since it's an interface and thus not
testable.

A new regex check was also added to ensure WorkManager.getInstance calls
always go through the new listener to avoid future situations where they
can accidentally trigger an instance creation when it's not wanted.

## 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
This is mainly an infrastructural change as it's literally fixing
whether the app can open at all on SDK 31+ devices, so there's not much
to show.
BenHenning added a commit that referenced this pull request Nov 23, 2022
## Explanation
Fixes #4750

This PR fixes issues that were introduced in #4747 when trying to use
the app on an actual API 31 device. The problems come from two breaking
changes in Android 12:
- Public activities, services, and providers must be marked as exported
(this only affected our SplashActivity).
- PendingIntents must be explicitly marked as mutable/immutable (this
only affects WorkManager, but that's tricky for us).

The WorkManager issue was fixed in version 2.7.0 (where we currently
depend on version 2.4.0), but we can't actually updated in a way that
would be low-risk to cherry-pick (since it would require updating our
Kotlin SDK to 1.5.x instead of 1.4.x). A safer option is to disable
WorkManager outright, but while doing this I discovered that we have
unrestricted getInstance() calls that will force WorkManager to get
created regardless. This was fixed by introducing a new
analytics-specific application creation listener and ensuring those do
not get called for SDK 31+. #4751 is tracking fixing this longer term.
Approximately 9% of our users will have analytics disabled until we
properly fix it & push a new release.

Note that I opted for a fix-forward instead of rolling back #4747 since
these are small PRs that need to be easily cherry-picked, and it's
guaranteed that the target SDK change be isolated to SDK 31 devices (so
developers would still be able to use the app on lower versions).

Proper testing for ensuring this works requires manual testing, for now
(as we don't have automated end-to-end tests). I manually verified that
the app opens and can be used on Android 12. One test exemption was
added for the new listener since it's an interface and thus not
testable.

A new regex check was also added to ensure WorkManager.getInstance calls
always go through the new listener to avoid future situations where they
can accidentally trigger an instance creation when it's not wanted.

## 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
This is mainly an infrastructural change as it's literally fixing
whether the app can open at all on SDK 31+ devices, so there's not much
to show.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Cherrypick completed Indicates a cherrypick request was approved & completed for a PR. PR: Cherrypick requested Indicates that a PR is being requested for being cherrypicked into the ongoing release branch. PR: LGTM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

App needs to be upgraded to SDK 31 in order to continue being able to be released on Play Store
2 participants