Unable to add Kotlin Android Extensions to my project

Viewed 28847

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

6 Answers

Android Studio 4.1

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
}

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'

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

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

Related