3

I am using gradle and I am trying to add kotlin to my project. But when I am trying to add 'kotlin-android-extensions' plugin for gradle it fails to find it.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Ziad Saad
  • 43
  • 2
  • 6

3 Answers3

4

To use the plugin, you have to add it in your root level file:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }
    ext.kotlin_version = '1.1.2-4'
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
1

Try to add the following to your gradle.build file

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

after that you have to make some changes in your dependencies classpath like this.

buildscript {
ext.kotlin_version = '1.1.60'
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

and in dependencies compile make sure to add jre7 such that.

compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

After doing all that rebuild the gradle and you are all done. This worked for me because i was facing the same problem you are now, and after this it's all done. Hope it works for you tooo....

0

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:+" try this