我正在维护其他人在 android studio 中编写的 android 应用程序的代码。
当我尝试将项目与 Gradle 文件同步时,我收到此错误消息:
23:46:27 UnsupportedMethodException
Failed to set up Android modules in project 'BuyTheWay': Unsupported method: SourceProvider.getJniDirectories().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
我使用的是0.8.14版本的android studio。
在对类似问题的回答中 Gradle DSL method not found: 'runProguard' ,建议在 build.gradle 文件中(在 app 文件夹中)替换以下行:
runProguard false
与
minifyEnabled false
但这对我没有帮助,因为编译器还在行中标记了“getDefaultProguardFile”
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
并声称:
cannot resolve symbol getDefaultProguardFile
尝试不同的方法,并更改 build.grale 在 gragle 文件夹中,求助
这是原始代码:
// 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.14.0'
}
}
allprojects {
repositories {
jcenter()
}
}
当我改变
classpath 'com.android.tools.build:gradle:0.14.0'
与
classpath 'com.android.tools.build:gradle:0.14.+'
并尝试将项目与 Gradle 文件同步,我收到此错误消息:
Error:(17, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:
The project 'BuyTheWay' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a>
The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a>
最佳答案
一个步骤可以解决这个问题。
buildTypes {
release {
apply plugin: 'eclipse'
runProguard false // <==== **remove this line**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
关于android studio - Gradle 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27304974/