cordova-android icon indicating copy to clipboard operation
cordova-android copied to clipboard

[RFC] feat: bump kotlin 1.8.0

Open erisu opened this issue 2 years ago • 6 comments

Motivation and Context

Use latest Kotlin

Description

Bump kotlin version 1.8.0

Tasks

  • [ ] Confirm 1.8.0 Usage

Kotlin's Release Details says that Android Studio comes with 1.7.20 and will get 1.7.21 in an update.

What is the side-effect of using 1.8.0 instead?

It appears to fetch and build the default app successfully...

Testing

npm t

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 avatar Jan 11 '23 02:01 erisu

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jan 11 '23 02:01 codecov-commenter

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 avatar Jan 30 '23 19:01 breautek

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.

breautek avatar Jan 30 '23 19:01 breautek

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.

kbrownlees avatar Mar 07 '23 01:03 kbrownlees

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

petercutting avatar Mar 07 '23 15:03 petercutting

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 avatar Apr 09 '23 23:04 breautek