Skip to content

Upgrade compileSdk to v36#735

Open
Harvester57 wants to merge 7 commits into
barbeau:masterfrom
Harvester57:upgrad-compilesdk
Open

Upgrade compileSdk to v36#735
Harvester57 wants to merge 7 commits into
barbeau:masterfrom
Harvester57:upgrad-compilesdk

Conversation

@Harvester57
Copy link
Copy Markdown
Contributor

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Acknowledge that you're contributing your code under Apache v2.0 license
  • Apply the AndroidStyle.xml style template to your code in Android Studio.

This PR upgrades the version of the SDK used for compiling to the latest version, and includes minor fixes to build cleanly.

try {
val info: PackageInfo = Application.app.packageManager.getPackageInfo(Application.app.packageName, 0)
versionName = info.versionName
versionName = info.versionName.toString()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Are these other changes necessary for compilesdk 36?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When just changing to target v36, throws the error:

Assignment type mismatch: actual type is 'kotlin.String?', but 'kotlin.String' was expected.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would you prefer to use the non-null assertion operator !! here ?

}

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When only changing the SDK version, throws an error without String?:

Class 'Preferences' is not abstract and does not implement abstract member 'onSharedPreferenceChanged'

override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
// A null key is passed when SharedPreferences are cleared, so we exit.
if (key == null) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added to handle the case when sharedPreferences is cleared and is null

if (SatelliteUtils.isRotationVectorSensorSupported(context)) {
// Use the modern rotation vector sensors
val vectorSensor: Sensor =
val vectorSensor: Sensor? =
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Throws the following error with v36:

Initializer type mismatch: expected 'android.hardware.Sensor', actual 'android.hardware.Sensor?'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is also aligned with the way we get the legacy sensor on line 145

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would you like to add a non-null test and log here, like:

if (vectorSensor != null) {
                    sensorManager.registerListener(
                        callback,
                        vectorSensor,
                        ROT_VECTOR_SENSOR_DELAY_MICROS
                    )
                } else {
                    Log.e(TAG, "Device doesn't support sensor TYPE_ROTATION_VECTOR")
                }

)
} else {
// No sensors to observe
} else {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indentation fix, no functional change here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants