简体   繁体   English

Android Studio-Gradle问题

[英]android studio - problems with Gradle

I making a code maintenance in of android app that someone else writed in android studio. 我在别人在android studio中写的android应用中进行代码维护。

when i try to sync project with Gradle files, i get this error message: 当我尝试与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.

I am using the 0.8.14 version of android studio. 我正在使用0.8.14版本的android studio。

In a anser to a similar queshtion Gradle DSL method not found: 'runProguard' , it was recommended to replace in the build.gradle file ( in the app folder ) the line: 未找到类似的问题Gradle DSL方法的分析器中:'runProguard' ,建议在build.gradle文件( 在app文件夹中 )替换以下行:

runProguard false

with

minifyEnabled false

but it dosent help for me, because the compiler also marks "getDefaultProguardFile" in the line 但这对我没有多大帮助,因为编译器还在该行中标记了“ getDefaultProguardFile”

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 

and clains that: 并声称:

cannot resolve symbol getDefaultProguardFile

trying a diffrent approach, and changing the build.grale in the gragle folder , dint help 尝试不同的方法,并更改gragle文件夹中的build.grale ,帮助

this is the original code: 这是原始代码:

// 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()
    }
}

when i change 当我改变

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

with

 classpath 'com.android.tools.build:gradle:0.14.+' 

and try to sync project with Gradle files, i get this error message: 并尝试与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>

One step can solve this problem. 一步可以解决这个问题。

buildTypes {
  release {
    apply plugin: 'eclipse'
    runProguard false // <==== **remove this line**
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM