繁体   English   中英

找不到 ID 为“Android”的插件

[英]Plugin with id 'Android' cannot be found

我已经从 eclipse 中完成了我的一个旧项目的 gradle 导出

将其导入android studio。 我收到错误:找不到 ID 为“Android”的插件

我发现了一些对此错误的引用,但这些建议对我不起作用,下面是我的 build.gradle 文件:

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

看来您弄错了 Gradle 插件标识符。

尝试用apply plugin: 'android' apply plugin: 'com.android.application'替换apply plugin: 'android' apply plugin: 'com.android.application'

这个build.gradle是错误的。

首先改变:

  apply plugin: 'android'

apply plugin: 'com.android.application'

然后dependencies块中删除classpath

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

最后为 android 插件添加一个带有类路径的buildscript块。

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

请注意。

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

是一个老插件。 你应该使用

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

可能需要更新 gradle 的版本。 您可以通过编辑文件gradle/wrapper/gradle-wrapper.properties:来做到这gradle/wrapper/gradle-wrapper.properties:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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