【发布时间】:2016-10-21 11:59:56
【问题描述】:
我正在尝试将 eclipse 项目迁移到 android studio,但出现以下错误,
错误:项目正在使用不受支持的 Android Gradle 插件版本 (0.12.2)。推荐的版本是 2.1.2。 修复插件版本和同步项目
这个问题是在 stackoverflow 中提出的,我尝试给出建议,但它对我不起作用。非常感谢任何帮助。
下面是我的 gradle 文件:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':appcompat_v7')
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
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')
}
}
下面是我的 gradle-wrapper.properties 文件:
#Mon Jun 20 13:18:24 IST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-1.10-all.zip
更新:-
将classpath 'com.android.tools.build:gradle:2.1.0' 添加到 ROOT/build.gradle 后,出现以下错误。
Error:(6, 0) Gradle DSL method not found: 'classpath()'
Possible causes:<ul><li>The project 'UberTest' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
<a href="fixGradleElements">Fix plugin version and sync project</a></li><li>The project 'UberTest' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
【问题讨论】:
-
你已经将你的 android studio 更新到 2.1
-
请添加您的顶级 build.gradle..!!
-
@jankigadhiya 我已经粘贴了整个 build.gradle。上面什么都没有。
-
我说的是你的 TOP LEVEL builg.gradle..!!这将在您的应用模块之外..!!会有另一个 build.gradle .. 其他然后这个..!!
-
@jankigadhiya 两个 gradle 是相同的,我检查过了。
标签: android eclipse android-studio android-gradle-plugin