android studio - Gradle 的问题

标签 android gradle android-studio

我正在维护其他人在 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/

相关文章:

kotlin - 将 Gradle 子项目与 Kotlin 多平台一起使用

android - 更新到 AndroidX Libraries 和 Gradle 3.4.2 后出现的问题

android - Android Studio 的最小工作 SpotBugs 设置

android - 设置LightTouchEnabled(假);已弃用 - 替代方案?

java - Libgdx Gwt 使用补间引擎编译错误

android - hdpi/ldpi/mdpi 的图形尺寸

android - 找不到项目的属性

android - 如何在 android studio 中检索签名 APK 的 key 别名和 key 密码(从 Eclipse 迁移)

android - 创建基础 PSD 来为 mdpi、320/480px 设备设计 Android App UI

java - GestureDetector.SimpleOnGestureListener 不考虑 View 比例因子?