【问题标题】:Can't import a project on Android Studio无法在 Android Studio 上导入项目
【发布时间】:2015-01-22 11:05:01
【问题描述】:

我最近从 Eclipse 迁移到了 Android Studio。我在 Gradle 方面遇到了一些问题。

我尝试从 github 导入这个项目:https://github.com/saulmm/Android-Material-Example,但是收到了这个错误信息:

错误:(16, 0) Gradle DSL 方法未找到:'runProguard()' 可能的原因:

  • 项目“Android-Material-Example-master”可能正在使用不包含该方法的 Gradle 版本。 打开 Gradle 包装文件
  • 构建文件可能缺少 Gradle 插件。 应用 Gradle 插件
  • 这是我的 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 文件并将runProguard() 的出现替换为minifyEnabled false
    • 在该 Github 项目的 app 文件夹中有一个 build.gradle 文件,其中包含 runProguard false 行。将此行更改为 minifyEnabled false
    • 你是对的,我检查了错误的 build.gradle 文件!

    标签: android android-studio android-gradle-plugin


    【解决方案1】:

    在 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.support.v7.widget.Toolbar'。我在安装了 Android API16 的设备上运行,但是 compileSdkVersion 要高得多。
    • 拜托看看stackoverflow.com/questions/26561235/…或许能帮到你
    猜你喜欢
    • 1970-01-01
    • 2019-05-30
    • 2014-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多