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

feat: bump kotlin 1.9.24 & drop kotlin-android-extensions when kotlin >= 1.8.0 #1543

Merged
merged 2 commits into from May 13, 2024

Conversation

erisu
Copy link
Member

@erisu erisu commented Jan 11, 2023

Motivation and Context

Use latest Kotlin

resolves #1692
resolves #1661 (Kotlin)
resolves #1642

Description

  • Bump Kotlin version 1.9.24
  • Do not apply kotlin-android-extensions plugin when Kotlin version is >= 1.8.0

Default projects do not enable Kotlin. If Kotlin is enabled, with the config preference GradlePluginKotlinEnabled, the default version 1.9.24 is applied.

<preference name="GradlePluginKotlinEnabled" value="true" />

App developers can change the Kotlin version with the following config preference GradlePluginKotlinVersion.

Example:

<preference name="GradlePluginKotlinVersion" value="1.7.22" />
  • If the Kotlin version is lower than 1.8.0, the kotlin-android-extensions plugin is applied to maintain previous implementation.
  • If Kotlin version is greater than or equal to 1.8.0, then the kotlin-android-extensions plugin is not applied as it was deprecated.

Kotlin Release Notes

Kotlin's Release says:

Starting from IntelliJ IDEA 2023.3 and Android Studio Iguana (2023.2.1) Canary 15, the Kotlin plugin is automatically updated. All you need to do is update the Kotlin version in your projects.

For Android Studio Giraffe and Hedgehog, the Kotlin plugin 1.9.10 will be delivered with upcoming Android Studios updates.

Testing

  • npm t
  • Cordova create, add platform, and build
  • Changed GradlePluginKotlinVersion to 1.7.22 to test ensure kotlin-android-extensions is applied.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@erisu erisu added this to the 12.0.0 milestone Jan 11, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.50%. Comparing base (89a0a72) to head (62a7f39).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1543   +/-   ##
=======================================
  Coverage   72.50%   72.50%           
=======================================
  Files          23       23           
  Lines        1837     1837           
=======================================
  Hits         1332     1332           
  Misses        505      505           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@breautek
Copy link
Contributor

Kotlin has a compatibility guide at https://kotlinlang.org/docs/compatibility-guide-18.html

It seems like they don't follow the "semver" rules and breaking changes may be introduced in "minor" versions.

As an example, some things changed with the when syntax as documented: https://kotlinlang.org/docs/compatibility-guide-18.html#deprecate-confusing-grammar-in-when-with-subject

1.6.20: introduce a deprecation warning on the affected expressions

1.8.0: raise this warning to an error, -XXLanguage:-ProhibitConfusingSyntaxInWhenBranches can be used to temporarily revert to the pre-1.8 behavior

>= 1.9: repurpose some deprecated constructs for new language features

There's a lot there, so given this information, if the Android SDK was built with compatibility of a specific kotlin version, we should try to follow that as our default as much as possible.

@breautek
Copy link
Contributor

Not sure how much this is relevant but there is also a Jetpack Compose Compiler package that does have explicit compatibility notes regarding kotlin

https://developer.android.com/jetpack/androidx/releases/compose-kotlin

For example, their latest release v1.4.0 introduces support for Kotlin 1.8.0.

@kbrownlees
Copy link

As a data point I recently had to upgrade my kotlin version to 1.7 because our builds started failing with a version mismatch issue.

Trying to use 1.8 failed to build, with the error:

e: The Android extensions ('kotlin-android-extensions') compiler plugin is no longer supported. Please use kotlin parcelize and view binding. More information: https://goo.gle/kotlin-android-extensions-deprecation

For context, to change you kotlin version set <preference name="GradlePluginKotlinVersion" value="1.7.22"/> in config.xml.

@petercutting
Copy link

I ran in to this build error today

Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.

Really frustrating when these errors appear for no apparent reason. The kotlin fix above worked so it was atleast an easy fix, when I eventually found it here.

I wonder if this fix will cause a new problem down the road when 1.7.22 isnt compatible with something else

@erisu erisu changed the title feat: bump kotlin 1.8.0 [RFC] feat: bump kotlin 1.8.0 Mar 9, 2023
@breautek
Copy link
Contributor

breautek commented Apr 9, 2023

I found another compatibility matrix in regards to gradle: https://docs.gradle.org/current/userguide/compatibility.html

As it stands right now, kotlin 1.8 is only officially supported on Gradle 8, which we aren't using yet (because it will require AGP 8).

I know folks already stated compatibility issues with kotlin 1.8, this is just a data point that might explain why there are compatibility issues.

@breautek breautek modified the milestones: 12.0.0, 13.x Apr 13, 2023
@erisu erisu modified the milestones: 13.x, 13.0.0 May 7, 2024
@erisu erisu changed the title [RFC] feat: bump kotlin 1.8.0 feat: bump kotlin 1.9.24 & drop kotlin-android-extensions when kotlin >= 1.8.0 May 8, 2024
@erisu erisu marked this pull request as ready for review May 8, 2024 03:34
@erisu erisu requested a review from breautek May 8, 2024 03:39
Copy link
Contributor

@breautek breautek 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, but I think this PR might be blocked by #1678

Because that PR bumps Gradle to 8.7 which I think is a requirement for >= kotlin 1.9.22.

@erisu erisu merged commit c2f315c into apache:master May 13, 2024
14 checks passed
@erisu erisu deleted the feat/kotlin-1.8.0 branch May 13, 2024 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants