24

When i try to add kotlin-android-extensions via:

apply plugin: 'kotlin-android-extensions'

to my project Android Studio tells me Plugin with 'kotlin-android-extensions not found??

What is going wrong? I am Running Android Studio 3.0 Canary 8

Rik van Velzen
  • 1,977
  • 1
  • 19
  • 37

6 Answers6

47

I think it's all about ordering, make sure you have plugin orders like that

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'
Jemo Mgebrishvili
  • 5,187
  • 7
  • 38
  • 63
13

Android Studio 4.1

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
}
Gabor Szigeti
  • 241
  • 2
  • 4
12

Please also consider that you must be careful about apply plugin: orders:

So in order to apply kotlin-android-extensions you must first apply kotlin-android. Same as the following coode:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
Ramin Ar
  • 1,213
  • 13
  • 10
3

you are all done good but you have to add the plugin id to dependencies classpath in your gradle file 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
  }
}

you always have to add that and after doing this, add the following in your gradle(app) file

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

and you are all done

1

In your gradle app:

apply plugin: 'kotlin-android-extensions'

and in your activity:

import kotlinx.android.synthetic.main.height_dialog_ft.*

Then you can use any id in your activity directly by their id name which your have mentioned in your .xml file

divibisan
  • 11,659
  • 11
  • 40
  • 58
abhilasha Yadav
  • 217
  • 1
  • 9
0

Ooops. I forgot to add the kotlin gradle plugin as mentioned here: https://kotlinlang.org/docs/reference/using-gradle.html#plugin-and-versions

Rik van Velzen
  • 1,977
  • 1
  • 19
  • 37