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(package_info_plus): Address changed fields nullability on Android 15 (API 35) #2975

Merged
merged 2 commits into from
Jul 9, 2024

Conversation

ChristianEdwardPadilla
Copy link
Contributor

@ChristianEdwardPadilla ChristianEdwardPadilla commented May 31, 2024

Description

This plugin fails to compile with the latest nullability signatures for Android 35

The compilation error messages are:

PackageInfoPlugin.kt:45:56: error: [UNSAFE_CALL] Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type ApplicationInfo?
                    put("appName", info.applicationInfo.loadLabel(packageManager).toString())
                                                       ^
PackageInfoPlugin.kt:47:36: error: [TYPE_MISMATCH] Type mismatch: inferred type is String? but String was expected
                    put("version", info.versionName)
                                   ^^^^^^^^^^^^^^^^
PackageInfoPlugin.kt:108:51: error: [SMARTCAST_IMPOSSIBLE] Smart cast to 'Array<(out) Signature!>' is impossible, because 'packageInfo.signatures' is a mutable property that could have been changed by this time
                if (signatures.isNullOrEmpty() || packageInfo.signatures.first() == null) {

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

@vbuberen
Copy link
Collaborator

Could you share how you were able to reproduce the compilation failure? In which setup? Because the plugin switched to compileSDK 34 quite some time ago and there were no issues with compilation.

I assume it is something happening with some different set of Android dependencies than the ones that we have in the example app, because I can't see any of these warnings and can run it successfully.

Copy link
Member

@miquelbeltran miquelbeltran left a comment

Choose a reason for hiding this comment

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

I haven't tested, but I believe this ? is not necessary.

@miquelbeltran
Copy link
Member

It is weird indeed that we haven't seen this compilation issues, but checking the documentation, these two methods versionName and applicationInfo can indeed return null, so adding the null checks seems correct to me.

@vbuberen
Copy link
Collaborator

It is weird indeed that we haven't seen this compilation issues, but checking the documentation, these two methods versionName and applicationInfo can indeed return null, so adding the null checks seems correct to me.

Yes, I also checked docs when was reviewing the PR a few days ago, but I am curios on how to get these compile issues from the PR description.

@ChristianEdwardPadilla
Copy link
Contributor Author

Apologies, the initial description was wrong. The new signatures are in API level 35: https://developer.android.com/about/versions/15

…kotlin/dev/fluttercommunity/plus/packageinfo/PackageInfoPlugin.kt

Co-authored-by: Miguel Beltran <[email protected]>
@vbuberen vbuberen changed the title fix(package_info_plus): fix PackageInfoPlugin.kt on latest Android 34 fix(package_info_plus): Address changed fields nullability on Android 15 (API 35) Jul 9, 2024
@vbuberen
Copy link
Collaborator

vbuberen commented Jul 9, 2024

Installed Android 15 (API 35) and validated the changes - everything is Ok.
Updated the title and description to a correct version.

@vbuberen
Copy link
Collaborator

vbuberen commented Jul 9, 2024

There is a failing integration test on Android API 34 which is not related to timeouts we usually have and not related to changes in this PR.
Will be addressed in another PR.

@vbuberen vbuberen merged commit dfa3bc2 into fluttercommunity:main Jul 9, 2024
21 of 23 checks passed
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.

3 participants