错误:(1, 0) 未找到 ID 为“com.android.application”的插件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24795079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error:(1, 0) Plugin with id 'com.android.application' not found
提问by Bob Kusik
This is my first attempt at Android Studio. I installed 0.8.0 and updated to 0.8.2. As soon as a project is created I get the error message:
这是我第一次尝试 Android Studio。我安装了 0.8.0 并更新到 0.8.2。一旦创建了项目,我就会收到错误消息:
Error:(1, 0) Plugin with id 'com.android.application' not found
错误:(1, 0) 未找到 ID 为“com.android.application”的插件
C:\Users\Bob\AndroidStudioProjects\HelloAgain6\app\build.gradle
C:\Users\Bob\AndroidStudioProjects\HelloAgain6\app\build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.bob.helloagain6"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
and C:\Users\Bob\AndroidStudioProjects\HelloAgain6\build.gradle
和 C:\Users\Bob\AndroidStudioProjects\HelloAgain6\build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
回答by Jared Burrows
Updated Answer (Apr. 10, 2020)
更新答案(2020 年 4 月 10 日)
Latest Gradle:6.3
最新版本:6.3
Version check:
版本检查:
./gradlew -v
./gradlew -v
How to update:
如何更新:
- Set URL:
./gradlew wrapper --gradle-version=3.6.2 --distribution-type=all
- Update:
./gradlew wrapper
- 设置网址:
./gradlew wrapper --gradle-version=3.6.2 --distribution-type=all
- 更新:
./gradlew wrapper
Latest Android Gradle Plugin:3.6.2
最新的 Android Gradle 插件:3.6.2
If you add the following code snippet to the topof your build.gradle
file. Gradle will update the build tools.
如果下面的代码片段添加到顶部您的build.gradle
文件。Gradle 将更新构建工具。
buildscript {
repositories {
google() // For Gradle 4.0+
maven { url 'https://maven.google.com' } // For Gradle < 4.0
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
}
}
Read more here: https://developer.android.com/studio/build/index.htmland about version compatibility here: https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradleand https://dl.google.com/dl/android/maven2/index.html.
在此处阅读更多信息:https: //developer.android.com/studio/build/index.html以及在此处了解版本兼容性:https: //developer.android.com/studio/releases/gradle-plugin.html#updating-gradle和https://dl.google.com/dl/android/maven2/index.html。
Original Answer
原答案
I had this same error, you need to make sure your Gradle version is compatible with your Android Gradle Plugin.
我遇到了同样的错误,您需要确保您的Gradle 版本与您的 Android Gradle 插件兼容。
The latest version of Gradle is 2.0but you need to use 1.12in order to use the Android Gradle Plugin.
Gradle 的最新版本是2.0,但您需要使用1.12才能使用 Android Gradle 插件。
回答by Ash
This can happen if you miss adding the Top-level build file.
如果您错过添加顶级构建文件,就会发生这种情况。
Just add build.gradleto top level.
只需将build.gradle添加到顶层即可。
It should look like this
它应该是这样的
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.xx.y'
}
}
allprojects {
repositories {
mavenCentral()
}
}
回答by Md Imran Choudhury
In my case, I download the project from GitHub and the Gradle file was missing. So I just create a new project with success build. Then copy-paste the Gradle missing file. And re-build the project is working for me.
就我而言,我从 GitHub 下载了该项目,但缺少 Gradle 文件。所以我只是创建了一个成功构建的新项目。然后复制粘贴 Gradle 丢失的文件。并重新构建该项目对我有用。
回答by Gennadiy Ryabkin
Root-gradle file:
根梯度文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:x.x.x'
}
}
allprojects {
repositories {
jcenter()
}
}
Gradle-wrapper.properties file:
Gradle-wrapper.properties 文件:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-x.x-all.zip
回答by Lorenzo Barbagli
I found the problem after one hour struggling with this error message:
一小时后我发现了这个错误消息的问题:
I accidentally renamed the root build.gradle
to filename in builde.gradle
, so Android Studio didn't recognize it anymore.
我不小心将 root 重命名build.gradle
为 filename in builde.gradle
,所以 Android Studio 不再识别它了。
Renamingit to build.gradle
resolved the issue!
重命名它以build.gradle
解决问题!
回答by Simon Fakir
I still got the error
我仍然收到错误
Could not find com.android.tools.build:gradle:3.0.0.
Problem: jcenter() did not have the required libs
问题:jcenter() 没有所需的库
Solution: add google() as repo
解决方案:添加 google() 作为 repo
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
}
}
回答by garnet
I am writing this not as a solution meant for many, but for some people who may commit a simple mistake like specifying the wrong url for importing projects from SVN. It is intended for those guys :)
我写这个不是为了解决很多人的问题,而是为了一些可能犯下简单错误的人,比如为从 SVN 导入项目指定错误的 url。它是为那些家伙准备的:)
This happened to me when I imported the project from SVN -> automatic prompt by Studio to open the project -> It asked for Gradle location -> D:\Software\Android\gradle-2.5 -> Then the error.
这发生在我从 SVN 导入项目时 -> Studio 自动提示打开项目 -> 它要求 Gradle 位置 -> D:\Software\Android\gradle-2.5 -> 然后是错误。
The same project in a different SVN branch works fine with the Gradle plugin and Gradle which I have configured in Studio. I tried changing Android Gradle plugin and Gradle to get it working on the erring branch without any success.
不同 SVN 分支中的同一个项目与我在 Studio 中配置的 Gradle 插件和 Gradle 一起工作得很好。我尝试更改 Android Gradle 插件和 Gradle 以使其在出错的分支上工作,但没有成功。
Finally, I figured out that it was my following mistake: I tried importing a specific Application alone instead of importing the application along with dependent library projects. The url which I used for import initially had the Application porject's name at the end. Once I removed it, and specified the parent directory which contained both application project and its dependent project, everything went smooth :)
最后,我发现这是我的以下错误:我尝试单独导入特定的应用程序,而不是将应用程序与依赖库项目一起导入。我最初用于导入的 url 末尾有应用程序项目的名称。一旦我删除它,并指定包含应用程序项目及其依赖项目的父目录,一切都很顺利:)
回答by Lancer.Yan
The other answers didn't work for me, I guess something wrong happens between ButterKnifeand 3.0.0 alpha5.
其他答案对我不起作用,我猜ButterKnife和3.0.0 alpha5之间发生了错误。
However, I found that when I annotated any one sentence, either BUtterKnife or 3.0.0 alpha5, it works normally.
但是,我发现当我注释任何一个句子时,无论是 BUtterKnife 还是 3.0.0 alpha5,它都可以正常工作。
So, you should just avoid the duplication or conflict.
所以,你应该避免重复或冲突。
回答by kreker
Check the spelling, mine was 'com.android.aplication'
检查拼写,我的是“com.android.a plication”
回答by Wouter Florijn
For future reference: For me, this issue was solely caused by the fact that I wasn't running Android Studio as administrator. I had the shortcut on Windows configured to always run as administrator, but after reinstalling Android Studio, the shortcut was replaced, and so it ran without administrator rights. This caused a lot of opaque errors, including the one in this question.
供以后参考:对我来说,这个问题完全是因为我没有以管理员身份运行 Android Studio。我将 Windows 上的快捷方式配置为始终以管理员身份运行,但在重新安装 Android Studio 后,快捷方式被替换,因此它在没有管理员权限的情况下运行。这导致了很多不透明的错误,包括这个问题中的错误。