How to set Kotlin version
Asked Answered
L

3

6

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.

Linetta answered 22/3, 2022 at 23:36 Comment(1)
why don't you try to use keywords for the link instead of just randomly pasting it? It makes it look congested. You can use it this way -> [Your text here](yourUrlHere). This is a sample test -> Click here to open stackoverflowFellers
D
11

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

Duky answered 29/3, 2022 at 3:33 Comment(5)
why don't you try to use keywords for the link instead of just randomly pasting it? It makes it look congested. You can use it this way -> [Your text here](yourUrlHere). This is a sample test -> Click here to open stackoverflowFellers
@Sambhav.K updated the comment. Thanks for the feedback. :)Duky
ok. its better now. But the links at the bottom can also be shortenedFellers
I tried this but it said it couldn't find apply plugin: 'kotlin-android' but when I change it to apply plugin: 'kotlin' it says The 'java' plugin has been applied, but it is not compatible with the Android plugins.Linetta
OK only applying step one is what works.Linetta
D
6

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

Dunnage answered 20/7, 2022 at 7:4 Comment(0)
D
0

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"
        }
    }

Then apply kotlin-android plugin to all the required module by adding following in required module's build.gradle file.

    plugins {
        ...
        id 'kotlin-android'
    }
Doublethink answered 5/10, 2023 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.