【问题标题】:Android Studio. Cannot compile/ build my project after updating安卓工作室。更新后无法编译/构建我的项目
【发布时间】:2014-03-14 07:41:24
【问题描述】:

刚刚将我的 android studio 更新到 0.5.1 并面临很多问题:

这是我的 build.gradle 文件:

buildscript {
repositories {
    maven { url 'http://download.crashlytics.com/maven' }
    }

    dependencies {
    }
}
apply plugin: 'android'
repositories {
    maven { url 'http://download.crashlytics.com/maven' }
}


android {
compileSdkVersion 19
buildToolsVersion '19.0.3'

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}

signingConfigs {
    release {
        storeFile file('dsc.jks')
        storePassword 'dscneo'
        keyAlias 'dsc'
        keyPassword 'dscneo'
    }
}

buildTypes {
    debug {
        versionNameSuffix '-DEBUG'
    }
    beta {
        versionNameSuffix '-BETA'
    }
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        signingConfig signingConfigs.release
    }
}

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/ASL2.0'
    }
}
dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile files('libs/gson-2.2.4.jar')
    compile files('libs/gson-2.2.4-sources.jar')
    compile files('libs/volley.jar')
    compile files('libs/gson-2.2.4-javadoc.jar')
    compile project(':HorizontalVariableListView')
    compile files('libs/sugar-1.2.jar')
    compile 'com.crashlytics.android:crashlytics:1.+'
    compile project(':shopify_view_pager')
    compile project(':shopify_smoothProgressBar_library')
    compile files('libs/butterknife-4.0.1.jar')
    compile project(':shopify_sliding_pane_library')
}

这是提示的错误:

Gradle 'shopping-app-android' project refresh failed:
         Build script error, unsupported Gradle DSL method found: 'release()'!
         Possible causes could be:  
         - you are using Gradle version where the method is absent 
         - you didn't apply Gradle plugin which provides the method
         - or there is a mistake in a build script

请帮忙!

我刚刚开始使用 Android Studio。

【问题讨论】:

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


    【解决方案1】:

    您似乎仍在运行 gradle 插件 0.8。见Migrating From 0.8 to 0.9

    【讨论】:

    • 我的项目的 build.gradle 有 classpath 'com.android.tools.build:gradle:0.9.+'
    • 日志在 release() 声明中提示问题。所以我删除了所有的发布声明和它现在的工作。
    • 我第一次安装 5.1 时也遇到了问题。我做的一件事是将 gradle 升级到 1.11 版。不确定这是否是必需的,但我发现在 Android Studio 中确保我使用的是最新的 Android Gradle 插件和相应的 Gradle 版本似乎很重要。
    猜你喜欢
    • 2019-03-27
    • 2017-11-30
    • 2019-09-26
    • 1970-01-01
    • 2017-08-12
    • 1970-01-01
    • 2017-09-08
    • 2021-10-20
    • 1970-01-01
    相关资源
    最近更新 更多