我正在尝试在Android工作室中打开移植的Android应用程序,当我尝试同步gradle时,我不断收到以下错误:Error:(1, 0) Plugin with id 'android' not found.
。我看过很多关于这个问题的帖子,但没有一个解决方案对我有帮助。这是我的gradle文件:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.google.android.gms:play-services:6.5.+'
compile 'com.getbase:floatingactionbutton:1.3.0'
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
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')
}
}
如果我做错了或者您需要其他信息,请告诉我。你能为我指出正确的方向吗?提前谢谢。
修改
我已在该问题中实现了答案,并得到了以下结果。请重新考虑
Error:Gradle version 1.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\Gerhardt\git\captis\gradle\wrapper\gradle-wrapper.properties to gradle-1.10-all.zip.
Please fix the project's Gradle settings.
<a href="openGradleSettings">Gradle settings</a>
所以我指的是版本2.2.1而且得到了这个:
Error:Could not find com.android.tools.build:gradle:2.2.1.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.jar
Required by:
:captis:unspecified
我无所适从。请告诉我?
答案 0 :(得分:2)
这是Error:(1, 0) Plugin with id 'android' not found的副本,但其代码的盲目复制粘贴会导致一些问题。
该问题建议您在构建脚本中放置buildscript
repositories
块,但由于答案引用了以前版本的Android Studio,因此它具有旧版本的Android Gradle插件,不幸的是,当发生这种情况时,Android Studio会给你一个无用且不正确的错误消息。这样做,注意classpath
语句中的较新版本。实际上,我假设您正在运行Studio 1.0或更高版本;如果您仍在运行测试版,则可能需要寻找合适的版本号:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}