Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'
}
like image 980
Islam Elbaz Avatar asked Sep 07 '17 17:09

Islam Elbaz


People also ask

Why is Kotlin Android extension gradle plugin deprecated?

They are not supported with Java. There are still projects that are written in Java and may not be fully migrated to Kotlin yet, and hence Kotlin Synthetics may not be a consistent way of getting the ViewIds in your project. Because of these issues, Kotlin Synthetics is now being deprecated.

How do I find my Kotlin plugin version?

You can check the Kotlin plugin version in Tools | Kotlin | Configure Kotlin Plugin Updates.


3 Answers

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.

like image 63
user1809913 Avatar answered Oct 18 '22 00:10

user1809913


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"
    }
}
like image 64
Md Imran Choudhury Avatar answered Oct 17 '22 23:10

Md Imran Choudhury


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!

like image 3
protanvir993 Avatar answered Oct 17 '22 22:10

protanvir993