android - 无法在 Android Studio 上导入项目

标签 android android-studio android-gradle-plugin

我最近从 Eclipse 迁移到了 Android Studio。我遇到了一些关于 Gradle 的问题。

我试图从 github 导入这个项目:https://github.com/saulmm/Android-Material-Example , 但收到此错误消息:

Error:(16, 0) Gradle DSL method not found: 'runProguard()' Possible causes:

  • The project 'Android-Material-Example-master' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • 这是我的build.gradle

    // 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:1.0.0'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        } }
    
    allprojects {
        repositories {
            jcenter()
        } }
    

    这是我的 gradle-wrapper.properties

    #Wed Apr 10 15:27:10 PDT 2013 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
    

    我找不到他们正在谈论的 runProguard()!有什么解决办法吗?

    最佳答案

    在 build.gradle 中试试这个:

    apply plugin: 'com.android.application'
    
    android {
        compileSdkVersion 20
        buildToolsVersion "20.0.0"
    
        defaultConfig {
            applicationId "package"
            minSdkVersion 14
            targetSdkVersion 20
            versionCode 1
            versionName "1.0.0"
        }
    
        buildTypes {
            release {
    
            /**
            *
            * Here is the change that must be done
            *
            **/
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
    }
    
    buildscript {
    
    }
    
    repositories {
    
    }
    
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:support-v13:19.+'
    }
    

    关于android - 无法在 Android Studio 上导入项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28087187/

    相关文章:

    java - 为什么 Map.getOrDefault() 会警告 NullPointerException?

    android - 每次在android studio中运行程序时,模拟器都会自动重启

    java - 我正在尝试将 junit 与 apt 插件一起使用

    java - 安卓事物 : How to install apk from device with pm install -r

    android - 如何以编程方式从设置中设置默认启动器?

    android - Activity 背景模糊,不知道后面是什么 Activity

    java - 每次都需要重建项目以反射(reflect) Android Studio Chipmunk 中的变化

    android - 从 Android Studio 运行应用程序时,在 Gradle 任务 processManifest.doLast 中编辑 AndroidManifest.xml 无效

    java - 使用 connectedInstrumentTest 构建 Android 作业不适用于 Jenkins

    Android辅助功能viewPager读取两个 View