gpt4 book ai didi

android - 不受支持的 Android Gradle 版本

转载 作者:行者123 更新时间:2023-12-02 02:22:38 24 4
gpt4 key购买 nike

我正在尝试将 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>

最佳答案

你的gradle版本太旧了。就像janki gadhiya所说,在你的TOP level build.gradle中(TOP level build.gradle是你的根目录,还有一个名为settings.gradle的文件),将gradle的版本更改为2.1.2:

        classpath 'com.android.tools.build:gradle:2.1.0'

然后同步你的gradle,一切都会好起来的。

另一种方法是重新打开您的项目,Android studio 应该提示您更新 gradle,然后单击“修复”。

关于android - 不受支持的 Android Gradle 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37918978/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com