我有一个使用Android Studio构建的Android项目并试图在我的Android Studio上导入并运行它,但在尝试同步项目时面临以下错误
Failed to sync Gradle project 'project-android'
Error:Gradle version 1.10 is required. Current version is 2.2.1. If using the gradle wrapper, try editing the distributionUrl in /Users/username/apps/android/project-android/gradle/wrapper/gradle-wrapper.properties to gradle-1.10-all.zip.
Please fix the project's Gradle settings in Gradle settings
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Android Studio Version : 1.0.1
那么如何解决上述错误
修改
更改@Grabiele所示的行后,我收到以下错误
Error:(22, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:
The project 'project-android' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin.
这是我在app/build.gradle
档案
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
答案 0 :(得分:18)
您必须更新:
适用于Android的Gradle插件
您必须在build.gradle
中更改此行:
classpath 'com.android.tools.build:gradle:0.9.+'
in
classpath 'com.android.tools.build:gradle:1.1.+'
Gradle版本
在gradle-wrapper.properties
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
在
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
关于 proguard 您必须在build.gradle
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
在
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
答案 1 :(得分:1)
除了@Gabriele回答
你应该改变
runProguard false
到
minifyEnabled false
答案 2 :(得分:0)
就我而言,我刚刚使用
"菜单>文件>无效缓存/重新启动>无效&重新启动"
我解决了。