DNA*_*DNA 1 android gradle android-gradle-plugin
更新项目后,我似乎收到此 Gradle 错误:
Configuration on demand is not supported by the current version of the Android Gradle plugin since you are using Gradle version 4.6 or above. Suggestion: disable configuration on demand by setting org.gradle.configureondemand=false in your gradle.properties file or use a Gradle version less than 4.6.
Run Code Online (Sandbox Code Playgroud)
打开选项卡进行进一步检查时,如下所示:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.android.application']
Caused by: org.gradle.api.tasks.StopExecutionException: Configuration on demand is not supported by the current version of the Android Gradle plugin since you are using Gradle version 4.6 or above. Suggestion: disable configuration on demand by setting org.gradle.configureondemand=false in your gradle.properties file or use a Gradle version less than 4.6.
Run Code Online (Sandbox Code Playgroud)
我已经尝试了它单独和一起提供的 2 个建议,但无济于事。请在下面查看我的 Gradle 文件。
Gradle 项目文件
buildscript {
ext.kotlin_version = '1.2.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:5.0.0"
classpath 'com.google.gms:google-services:4.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
Gradle 模块文件
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'
apply plugin: 'kotlin-kapt'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 27
defaultConfig {
applicationId "com.example.blah.blah"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFile 'proguard-rules.pro'
}
}
}}
dependencies {
implementation 'com.stripe:stripe-android:6.1.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'junit:junit:4.12'
implementation "cz.msebera.android:httpclient:4.4.1.2"
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-core-utils:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation files('libs/stripe-java-5.23.1.jar')
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.google.code.gson:gson:2.8.2'}
apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)
Gradle 属性文件
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
#org.gradle.parallel=true
Run Code Online (Sandbox Code Playgroud)
我希望有人能启发我。如果您需要,我会上传更多文件数据。
根据错误。你需要
当前版本的 Android Gradle 插件不支持按需配置,因为您使用的是 Gradle 4.6 或更高版本。建议:通过设置需求禁用配置
org.gradle.configureondemand=false
in
您的gradle.properties
文件或使用一个摇篮版本低于4.6。
也是
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
org.gradle.configureondemand=false
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
#org.gradle.parallel=true
Run Code Online (Sandbox Code Playgroud)
注意:IDE 中还有一个“按需配置”选项(在搜索工具中搜索,您会在“编译器”选项下找到它)取消选中该选项并在全局 gradle 属性文件中添加“org.gradle.configureondemand=false”通常在 C 驱动器(windows)或您的操作系统分区(MAC 或 linux)中,不要忘记启用隐藏文件(windows-> 查看选项和 Mac command+shift+。)
查找更多信息
或者您也可以降级您的 gradle 版本。
转到Project->Gradle->wrapper
并打开gradle-wrapper.properties
文件
并将其值更改distributionUrl
为
distributionUrl = https\://services.gradle.org/distributions/gradle-4.4-all.zip
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5020 次 |
最近记录: |