当前位置 : 主页 > 手机开发 > android >

android – 构建脚本错误,发现不支持的Gradle DSL方法:’release()’!当uograded到0

来源:互联网 收集:自由互联 发布时间:2021-06-11
无法解决此错误,我已更新 Android工作室.走了其他 this解决方案,但没有为我工作,请帮助.. 构建脚本错误,发现不支持的Gradle DSL方法:’release()’! 可能的原因可能是: – 您正在使用没有
无法解决此错误,我已更新 Android工作室.走了其他 this解决方案,但没有为我工作,请帮助..

构建脚本错误,发现不支持的Gradle DSL方法:’release()’!
        可能的原因可能是:
         – 您正在使用没有方法的Gradle版本
         – 您没有应用提供该方法的Gradle插件
         – 或者构建脚本中存在错误
        Gradle设置

Gradle版本 – 0.9

主要的gradle.

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }

}
apply plugin: 'android'

android {
    compileSdkVersion 19

    buildToolsVersion "19.0.0"

}

Project Gradle文件

apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 17
    buildToolsVersion '18.0.1'

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 17
    }

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

    buildTypes {
        debug {
            versionNameSuffix '-DEBUG'
        }
        beta {
            versionNameSuffix '-BETA'
        }
        release {
            signingConfig signingConfigs.release
        }
    }


}

dependencies {
    compile 'com.google.android.gms:play-services:3.1.36'
    compile 'com.android.support:appcompat-v7:18.0.+'
    compile 'com.android.support:support-v4:+'
    compile files('libs/libGoogleAnalyticsServices.jar')
    compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
    compile files('libs/signpost-core-1.2.1.1.jar')
    compile files('libs/gson-2.1.jar')
    compile project(':facebook')
    compile project(':TabIndicatorLibrary')
    compile files('libs/YouTubeAndroidPlayerApi.jar')
    compile project(':VerticalViewPager')
    compile files('libs/universal-image-loader-1.9.1.jar')
    compile files('libs/universal-image-loader-1.9.1-sources.jar')
    compile files('libs/twitter4j-core-3.0.5.jar')
    compile files('libs/HockeySDK-3.0.1.jar')
}

Facebook SDK gradle文件

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
}

android {
    compileSdkVersion 17
    buildToolsVersion "18.0.1"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

其他库项目gradle文件

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}
apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
}

android {
    compileSdkVersion 16
    buildToolsVersion '18.0.1'

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
}

还有一个库项目gradle文件.

apply plugin: 'android-library'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 18
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 16
        versionCode 1
        versionName "1.0"
    }
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
}
在您的上一个文件(库)中,您在android块中有释放块.

现在,库项目的DSL与应用程序项目的DSL相同

在特殊情况下,您必须将release块放在buildTypes中.

android {
    buildTypes {           
        release {
        }
    }

另外,我建议您使用buildToolsVersion ’19 .0.x’作为所有gradle文件.

您可以将它放在根文件夹中的build.gradle中.

ext {
    compileSdkVersion = 19
    buildToolsVersion = "19.0.3"
}

然后在每个build.gradle文件中,您可以使用:

compileSdkVersion rootProject.ext.compileSdkVersion
 buildToolsVersion rootProject.ext.buildToolsVersion
网友评论