Fixing `Google Api Error: apkNotificationMessageKeyTargetSdkVersionTooLow`

I started receiving this error message when updating my apps to the Play Store:

Google Api Error: apkNotificationMessageKeyTargetSdkVersionTooLow: Your app currently targets API level 27 and must target at least API level 28.

To fix it, I upgraded the version in build.gradle from:

android {
    compileSdkVersion 28
    ...
    defaultConfig {
        applicationId "..."
        minSdkVersion 21
        targetSdkVersion 27
        ...

To:

android {
    compileSdkVersion 28
    ...
    defaultConfig {
        applicationId "..."
        minSdkVersion 21
        targetSdkVersion 28
        ...

The change was officially announced a while back at https://android-developers.googleblog.com/2019/02/expanding-target-api-level-requirements.html. And they refer to a prior article about why it is required. Read more at https://android-developers.googleblog.com/2017/12/improving-app-security-and-performance.html.

Note to self: read the Android Developers Blog from time to time!