Search code examples
react-nativekotlingradleandroid-gradle-plugingradle-plugin

How to set a new kotlin and gradle version in React Native?


I have to use a lib called watermelondb, and, to use that, I have to get at least the 1.3.5 kotlin version, and my current version is 1.3.21, and when I try to set 1.3.5 I get an error that says:

Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-6.2-all.zip'.
A problem occurred configuring root project 'espeleoapp'.
Could not resolve all artifacts for configuration ':classpath'.
Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.5.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.5/kotlin-gradle-plugin-1.3.5.pom
  - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.5/kotlin-gradle-plugin-1.3.5.pom
Required by:
    project :Java(0)

My build.gradle buildcript is like this:

buildscript {
    ext.kotlin_version = '1.3.21'

    ext {
        buildToolsVersion = "30.0.0"
        minSdkVersion = 16
        compileSdkVersion = 30
        targetSdkVersion = 30
        supportLibVersion = "30.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

and my gradle-wrapper.properties is like this:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

what do I have to change to get the correct kotlin version?

I tried to use differents versions, but didn't work


Solution

  • I was having similar issues just Yesterday. This might help.

    buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 31
        targetSdkVersion = 31
        kotlinVersion = "1.5.31"
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.2.1")
        classpath("com.google.gms:google-services:4.2.0")
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    

    }