我在Android应用程序中进行代码维护,其他人在android studio中编写。
当我尝试将项目与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'
和clains:
cannot resolve symbol getDefaultProguardFile
尝试不同的方法,并更改gragle文件夹中的build.grale ,dint help
这是原始代码:
// 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>
答案 0 :(得分:2)
一步可以解决这个问题。
buildTypes {
release {
apply plugin: 'eclipse'
runProguard false // <==== **remove this line**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}