简体   繁体   中英

Plugin with id 'Android' cannot be found

I've done a gradle export of an old project of mine from eclipse and

imported it into android studio. I get the error: Plugin with id 'Android' cannot be found

I've found a few references to this error but the suggestions didnt work for me, below is my build.gradle file:

apply plugin: 'android'

dependencies {
classpath 'com.android.tools.build:gradle:0.11.+'
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':Panic Phase 2:PanicPhase2:PanicAndroid:facebook-android-sdk-master:facebook')
    compile project(':google_play_services:libproject:google-play-services_lib')
}

android {
    compileSdkVersion 11
    buildToolsVersion "23.0.0 rc3"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

It seems you got the Gradle plugin identifier wrong.

Try replacing apply plugin: 'android' with apply plugin: 'com.android.application'

This build.gradle is wrong.

First of all change:

  apply plugin: 'android'

to

apply plugin: 'com.android.application'

Then remove the classpath from the dependencies block:

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':Panic Phase 2:PanicPhase2:PanicAndroid:facebook-android-sdk-master:facebook')
    compile project(':google_play_services:libproject:google-play-services_lib')
}

Finally add a buildscript block with your classpath for android plugin.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.11.+' 
    }
}

Pay attention.

classpath 'com.android.tools.build:gradle:0.11.+' 

is an old plugin. You should use

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

It may require to update the version of gradle. You can do that by editing the file gradle/wrapper/gradle-wrapper.properties:

distributionUrl=http\://services.gradle.org/distributions/gradle-2.4-all.zip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM