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

fix: Build errors due to old kotlin and gradle versions

Open amrsalah3 opened this issue 11 months ago • 1 comments

Fixes #893 here.

The project fails to build due to the old Kotlin version that can't use kotlinx.serialization library. Also, the library changed its dependencies declaration from the older versions. After several attempts to solve the unsupported versions and the resulting issues due to changing the versions in the project, what works eventually is the following:

Changes:

  1. Upgrade Kotlin versions in the project to 1.9.0
  2. Upgrade Gradle version to 6.8.3 and Android Gradle Plugin to 4.2.2 to be compatible with the Kotlin version.
  3. Upgrade kotlinx serialization library version to 1.6.2 and change the obsolete dependency name from kotlinx-serialization-runtime to kotlinx-serialization-json and change the code in JSONHelper.kt file to the new API provided by the library.
  4. Due to the previous upgrades, kotlin-android-extensions plugin (which provides Kotlin synthetics and parcelization) is now unsupported because it was an experimental plugin, and it is not possible to build the project with it. Therefore, we need to migrate from Kotlin synthetics to Jetpack View Binding. In addition, we need to use kotlin-parcelize plugin for parcelization.
  5. After the migration to ViewBinding, the plugin com.diffplug.spotless and ktlint() are now working properly and they automatically modified the whole project to comply with the Kotlin linting.

amrsalah3 avatar Mar 03 '24 12:03 amrsalah3