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

Android StudioAndroid Studio-3.0Kotlin Android-Extensions

Android Studio Problem Overview


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'
}

Android Studio Solutions


Solution 1 - Android Studio

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.

Solution 2 - Android Studio

> 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"
    }
}

Solution 3 - Android Studio

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!

Solution 4 - Android Studio

put the below lines in build.gradle app

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

and also do 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
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIslam ElbazView Question on Stackoverflow
Solution 1 - Android Studiouser1809913View Answer on Stackoverflow
Solution 2 - Android StudioMd Imran ChoudhuryView Answer on Stackoverflow
Solution 3 - Android Studiotanvir993View Answer on Stackoverflow
Solution 4 - Android StudioMazhar IqbalView Answer on Stackoverflow