Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Upgrade app to target and compile level 31 #210

Merged
merged 1 commit into from
Mar 27, 2023

Conversation

ktohalloran
Copy link
Contributor

Overview

This PR updates the target and compile level to 31.

Notes

This PR does the absolute minimum on this. There are still quite a few linting warnings and other errors, which I've investigated and ultimately determined could be separated out into issue #209. Other than updating the target and compile SDK version numbers, version code, and version name, this PR also updates the import for the AndroidWorkManager, as this changed with the update to 31, and adds the option to share approximate, rather than precise, location, as required by the update.

Testing Instructions

  • Follow instructions from README to set up the project
  • Set the build variant to "debug" and add two new emulators to run SDK versions 21 and version 31
  • Select one of your new emulators from the dropdown and click "debug" in the top righthand corner of Android Studio
  • Allow the app to launch and then click around, paying attention to the logs in the "debug" window (found in the bottom lefthand corner of the screen)
  • Make sure that everything works as expected and that the only errors are those described in issue Fix linting warnings and errors on SDK version 31 #209

Closes #201

This commit also updates the Android WorkManager import statement
to fix FLAG_MUTABLE and FLAG_IMMUTABLE errors.
Copy link
Contributor

@ddohler ddohler left a comment

Choose a reason for hiding this comment

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

Looks good! I did not actually test because spinning up Android Studio is A Process, but everything that's here makes sens to me.

@@ -4,6 +4,7 @@
package="org.gophillygo.app">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Copy link
Contributor

Choose a reason for hiding this comment

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

The docs are a bit confusing here; the written docs say this (emphases mine):

You declare a need for foreground location when your app requests either the ACCESS_COARSE_LOCATION permission or the ACCESS_FINE_LOCATION permission, as shown in the following snippet:

And then the snippet says:

<manifest ... >
  <!-- Always include this permission -->
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

  <!-- Include only if your app benefits from precise location access. -->
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

Anyway, it sounds reasonable to me that we trust the code snippet over the written docs, but I am curious whether you encountered an error or some other behavior that caused you to add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was referencing the Android developer docs pages on the upgrade and on requesting location access at runtime on this upgrade, which say:

On Android 12 (API level 31) or higher, users can request that your app retrieve only approximate location information, even when your app requests the ACCESS_FINE_LOCATION runtime permission.

To handle this potential user behavior, don't request the ACCESS_FINE_LOCATION permission by itself. Instead, request both the ACCESS_FINE_LOCATION permission and the ACCESS_COARSE_LOCATION permission in a single runtime request.

This is in line with the errors I saw while testing the app, which did not allow me to only request only ACCESS_FINE_LOCATION.

@ktohalloran ktohalloran merged commit 119444b into develop Mar 27, 2023
@ktohalloran ktohalloran deleted the feature/kob/upgrade-to-sdk-31 branch March 27, 2023 11:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Android SDK version 31 by August 31, 2023
2 participants