【问题标题】:Plugin with id 'Android' cannot be found找不到 ID 为“Android”的插件
【发布时间】:2015-08-25 16:09:13
【问题描述】:

我已经从 eclipse 和

中导出了我的一个旧项目

将其导入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')
    }
}

【问题讨论】:

    标签: java android android-studio gradle build.gradle


    【解决方案1】:

    您似乎弄错了 Gradle 插件标识符。

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

    【讨论】:

      【解决方案2】:

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

      最后添加一个 buildscript 块与您的 android 插件的类路径。

      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:来做到这一点

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-02
        • 1970-01-01
        • 1970-01-01
        • 2017-01-20
        • 2014-08-03
        相关资源
        最近更新 更多