Error:(1, 0) Plugin with id 'kotlin-android-extensions' not found
Asked Answered
U

5

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

When i add this extensions in android studio preview, give me this error "Error:(1, 0) Plugin with id 'kotlin-android-extensions' not found.".

My build gradle

   apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.example.mohamed_elbaz.myapplication"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Unstrung answered 7/9, 2017 at 17:13 Comment(2)
Show your build.gradle.Ergotism
kotlin-android-extensions is not supported anymore use viewbindingDermatoplasty
M
85

The build.gradle snippet you posted looks like the config inside your app module. What does the build.gradle in your project's root directory look like? To add the kotlin plugin dependencies it should look something like this:

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        jcenter()
        google()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta6'
        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
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

The important part being the line classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"which adds the kotlin plugins.

Midget answered 22/9, 2017 at 22:15 Comment(1)
You can find what is the latest kotlin plugin version here: plugins.jetbrains.com/plugin/6954-kotlinChiffon
C
67

To use the plugin, you have to add it in your root build.gradle file

buildscript {
ext.kotlin_version = '1.1.60'
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
Clangor answered 21/11, 2017 at 14:57 Comment(1)
You can find what is the latest kotlin plugin version here: plugins.jetbrains.com/plugin/6954-kotlinMilligram
B
3

In Android Studio we can fix it in following ways:_

Using the plugins Domain Specific Language (DSL) in App Level Graddle:

plugins {
    id "org.jetbrains.kotlin.android.extensions" version "1.4.21"
}

That's all to fix it.

But if you're using legacy plugin application, then add the following in App Level Gradle:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21"
  }
}

apply plugin: "org.jetbrains.kotlin.android.extensions"

Hopefully, it'll be helpful!

Brutalize answered 15/12, 2020 at 6:51 Comment(1)
You can find the latest kotlin plugin version here: plugins.jetbrains.com/plugin/6954-kotlinAdmixture
P
2

Add the following lines in build.gradle app:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

Also make changes in build gradle by adding kotlin extension and path:

//put the ext above the dependency line//

ext.kotlin_version = '1.4.31'
dependencies {
    classpath "com.android.tools.build:gradle:4.2.1"
    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
}
Pulcheria answered 27/11, 2021 at 9:9 Comment(1)
You can find the latest kotlin plugin version here: plugins.jetbrains.com/plugin/6954-kotlinAdmixture
E
0

in Android Studio Hedgehog | 2023.1.1

build.gradle Project:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.2.0' apply false
id "com.google.gms.google-services" version "4.3.14" apply false
id 'org.jetbrains.kotlin.android' version '1.9.10' apply false // add
}

build.gradle app:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'
    id 'org.jetbrains.kotlin.android'
}
android {
....

    kotlinOptions {
        jvmTarget = "1.8"
    }

}
dependencies {
 implementation("androidx.core:core-ktx:1.12.0")
}
Expostulate answered 25/1 at 9:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.