Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Kotlin version

Hello I'm facing the following error when building the android portion of https://github.com/jitsi/jitsi-meet

'let((T) -> R): R' is only available since Kotlin 1.3.50 and cannot be used in Kotlin 1.3

on line Screen.kt#L156

In Android Studio settings shows using Kotlin 1.6 in the compiler settings and when I set a project variable kotlinVersion in build.gradle to 1.6.10 I still get the same error.

like image 777
William Lohan Avatar asked Aug 27 '26 13:08

William Lohan


2 Answers

As per the codebase, I observed that the react-native-screens project is using Kotlin for their development. Whereas in you project, you are implementing your project in pure Java.

So, to use this library, you would need to add kotlin support in your project. To do so, please add following code snippet in your project level build.gradle

  1. In buildscript's dependencies block add kotlin classpath:
// Project build.gradle file.
buildscript {
    ext.kotlin_version = '1.4.10'
    ...
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
  1. Then apply kotlin-android plugin to all the required module by adding following in required module's build.gradle file.
plugins {
    ...
    id 'kotlin-android'
}

You can find the same implementation in the library at react-native-screens build.gradle Line 12 and react-native-screens build.gradle Line 23.

Ref: https://developer.android.com/kotlin/add-kotlin

like image 108
Ashok Avatar answered Aug 30 '26 04:08

Ashok


Update android/build.gradle as follows:

{
  buildscript {
    ext {
      ...
      kotlinVersion = "1.5.31"
    }
    dependencies { 
      classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
    }
  }
}

enter image description here

like image 33
lakshan sampath Avatar answered Aug 30 '26 03:08

lakshan sampath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!