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

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

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.

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

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!

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
}

Related

Android Studio GridLayout not working. Shows completely grey into Design View

I hope someone can help me with this :S
I am working on Android Studio 3.6.2 and Gradle version is 5.6.4.
I just tried to drag and drop a GridLayout into a ConstraintLayout. But for some reason the GridLayout shows completely grey.
I read in my research that could be something related with the Gradle files. I read I need:
1) implementation 'androidx.gridlayout:gridlayout:1.0.0'
2)
repositories {
google()
}
I have these two included in my Gradle files. So, am I missing something somewhere?
I upload a reference image and some code. Thanks in advance ;)
Design View
build.gradle (Project: AndroidSample)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.aretius.androidsample"
minSdkVersion 26
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
}
build.gradle (Module: app)
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Well, I finally solved my problem reinstalling Android Studio with the latest version of it :)

Error:Failed to resolve: runtime

so my project was working fine yesterday and I tried to open it today and it gives me that error , help would be much appreciated
I tried to search for a long time about whats going wrong but it seems all answers not working with me
Error:Failed to resolve: runtime
Open File
here is build.gradle(Project) file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and here is build app profile
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.android.writer"
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.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-database:11.0.4'
implementation 'com.google.firebase:firebase-auth:11.0.4'
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'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.android.support:design:26.1.0'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.firebase:firebase-client-android:2.5.2+'
}
apply plugin: 'com.google.gms.google-services'
Based on the answer in Android Studio 3.1.2 : Failed to resolve: runtime, try changing the order of imports in build.gradle project file as
allprojects {
repositories {
google()
maven {
url "https://maven.google.com" // Google's Maven repository
}
jcenter()
}
}
This worked for me.
This is very weird and took me almost 4-5 hours to fix. But, it turns out you need to put google() at the top and jcenter() at the bottom of repositories in build files for all modules. Maven can go in between and it'll be fixed.
allprojects {
repositories {
google()
maven {
url "https://maven.google.com" // Google's Maven repository
}
jcenter()
}
}
You must place google() as the 1st line. Reminder First line. I hope it will help you.
This worked for me
repositories {
google()`Goolge repo`
jcenter()
maven {
url 'https://maven.google.com/ `Google maven repo`
name 'Google'
}
}

lombok fails when compile with Gradle 4.5 in Android Studio 3.1.2

I want to use lombok in my Android Studio project.
My current build.gradle project file looks like this:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And my app build.gradle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "app.getter.android"
minSdkVersion 16
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'
}
customDebugType {
debuggable true
}
}
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.16.20'
annotationProcessor 'org.projectlombok:lombok:1.16.20'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
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'
}
I've already installed Lombok Plugin in my Android Studio 3.1.2 and all seems correct. All the lombok tools are available tu use it. The content assist shows all lombok dependencies and there isn't compilation errors in my workspace. However when I try to run a test, Gradle compiles my code and it can't find the lombok generated code like getters/setters or val variables are not transformed to my Java type so it seems that annotationProcessor is not invoked before the compilation or the generated code by the annotationProcessor isn't in the classpath when gradle makes the compilation.
I've tried to use gradle-lombok-plugin but nothing works for me. What I'm doing wrong?

jitpack.io dependencies are not working

I cannot get jitpack.io dependencies to work with gradle. I know there are other questions but none of the suggested tips helped. The problem is, jitpack.io dependencies are not working at all. In theory it should be simple... add the mavel { url ... } and the compile declarative. But i keep getting an error that the dependency cannot be resolved.
I updated android-studio, which suggested to update and then updated gradle. Since every jitpack.io dependency is not working, it must be related to the configuration of gradle overall. Unfortunately i have no clou where to start.
I tried different repositories, so that should not be the problem. I also checked the corresponding build logs.
Can anybody help me?
This are my whole gradle files, they should be fine.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url "http://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
and
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "patrickstummer.com.bonario_internal"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.github.soroushjavdan:ApplicationLocker:62301ce0b4'
}
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Add the dependency
dependencies {
compile 'com.github.User:Repo:Tag'
}

Showing error fix plugin version and sync projects in android studio

i am new in Android Studioand when i create a new project suddenly i just got an error message i.e, Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "9ba5989c7b283b0ec145cc20641f7155619d6148"
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "************"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
My build.gradle(project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
i have updated my Android studio 2.0 but it always showing Fix plugin version and sync project when open create a project.please anyone can tell me what i should do to rectify this problem.
Thanks in advance...
classpath 'com.android.tools.build:gradle:2.0.0-alpha2' instead of this use
classpath 'com.android.tools.build:gradle:2.2.+' this fixed the same error for me!

Resources