gpt4 book ai didi

android - 构建脚本错误,升级到 0.5.1 时发现不支持的 Gradle DSL 方法为 : 'release()' !

转载 作者:太空宇宙 更新时间:2023-11-03 12:19:01 38 4
gpt4 key购买 nike

无法解决这个错误,我已经更新了 Android studio。经历了其他this解决方案但对我不起作用,请帮助..

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

Gradle 版本 - 0.9

主要等级。

// 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"

}

项目 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 渐变文件

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 block 中有 release block 。

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

特别是您必须将 release block 放在 buildTypes 中。

android {
buildTypes {
release {
}
}

此外,我建议您对所有 gradle 文件使用 buildToolsVersion '19.0.x'

你可以把它放在根目录下的 build.gradle 中。

ext {
compileSdkVersion = 19
buildToolsVersion = "19.0.3"
}

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

 compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

关于android - 构建脚本错误,升级到 0.5.1 时发现不支持的 Gradle DSL 方法为 : 'release()' !,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22370895/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com