[英]Plugin with id 'Android' cannot be found
I've done a gradle export of an old project of mine from eclipse and我已经从 eclipse 中完成了我的一个旧项目的 gradle 导出
imported it into android studio.
将其导入android studio。 I get the error: Plugin with id 'Android' cannot be found
我收到错误:找不到 ID 为“Android”的插件
I've found a few references to this error but the suggestions didnt work for me, below is my build.gradle file:我发现了一些对此错误的引用,但这些建议对我不起作用,下面是我的 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')
}
}
It seems you got the Gradle plugin identifier wrong.看来您弄错了 Gradle 插件标识符。
Try replacing apply plugin: 'android'
with apply plugin: 'com.android.application'
尝试用
apply plugin: 'android'
apply plugin: 'com.android.application'
替换apply plugin: 'android'
apply plugin: 'com.android.application'
This build.gradle
is wrong.这个
build.gradle
是错误的。
First of all change:首先改变:
apply plugin: 'android'
to到
apply plugin: 'com.android.application'
Then remove the classpath
from the dependencies
block:然后从
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')
}
Finally add a buildscript
block with your classpath for android plugin.最后为 android 插件添加一个带有类路径的
buildscript
块。
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.可能需要更新 gradle 的版本。 You can do that by editing the file
gradle/wrapper/gradle-wrapper.properties:
您可以通过编辑文件
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.