Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio - Failed to apply plugin [id 'com.android.application']

I am working on an app. In my app there is no error in code but when I try to run my project it gives following errors.

Error:(1, 1) A problem occurred evaluating project ':app'.

Failed to apply plugin [id 'com.android.application']

Could not create plugin of type 'AppPlugin'.

I try this also Gradle is issuing an error "Could not create plugin of type 'AppPlugin'"

and this also Gradle errors in Android Studio

Following is my build.gradle file

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {

    compileSdkVersion 23
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.praval.healthfreak"
        minSdkVersion 15
        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.2.1'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.android.support:design:23.2.1'
    compile files('libs/YouTubeAndroidPlayerApi.jar')

}
like image 870
Praval Sharma Avatar asked May 07 '16 09:05

Praval Sharma


People also ask

What is Android plugin application?

apply plugin: 'android' specifies that It's an Android project but it does not specify Its an Application or Library project. To make life easier you can tell gradle the type of project and indicate which plugin should be used. I recommend to use apply plugin: 'com. android.


3 Answers

Updated June 24, 2020

You need to update to the latest gradle version to solve this issue.

Please make sure you are on the latest Android Studio

and then update your project level build.gradle by updating this dependency

buildscript {
    repositories {
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'
    }
}

It might show a popup asking your permission to update gradle, please update and it will download the latest distribution automatically and the issue will be resolved.

Or else you can

Get Latest Gradle 5.6.4 from here and Add it manually

If you don't want to download it manually:

Open YourProject > gradle > wrapper > gradle-wrapper.properties and replace

distributionUrl=https\://services.gradle.org/distributions/gradle-version-number-all.zip

With

distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

Rebuild the project or just run gradle sync again.

like image 154
Max Avatar answered Oct 08 '22 05:10

Max


I faced the same issue in Android Studio version 3.5.3. This is how i fixed it.

I updated the dependecy com.android.tools.build:gradle in my project level build.gradle file from a lower version to 3.5.3 as below.

classpath 'com.android.tools.build:gradle:3.5.3'

I then went ahead and edited the value of distributionUrl in gradle-wrapper.properties file as below. This file is in the directory /gradle/wrapper/ from the root of your project folder.

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
like image 11
Nicodemus Ojwee Avatar answered Oct 08 '22 04:10

Nicodemus Ojwee


I found the simplest answer to this.

Just go gradle.properties file and change the enableUnitTestBinaryResources from true to false

android.enableUnitTestBinaryResources=false

The snapshot is shown below

enter image description here

like image 11
Tonnie Avatar answered Oct 08 '22 06:10

Tonnie