Error:Could not determine the dependencies of task ':app:preDebugBuild'
Error:Could not determine the dependencies of task ':app:preDebugBuild'
我已更新到 Android Studio 3.0.1,但我的控制台出现此错误:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :libraries:Jumble:generateDebugSources, :libraries:Jumble:generateDebugAndroidTestSources, :libraries:Jumble:mockableAndroidJar]
Error:Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve project :libraries:Jumble.
Required by:
project :app
> Cannot choose between the following configurations of project :libraries:Jumble:
- debugRuntimeElements
- releaseRuntimeElements
All of them match the consumer attributes:
- Configuration 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
- Configuration 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
更新后出现此问题的原因是什么?
问题已解决!
我的应用程序在根文件夹中没有 build.gradle
文件。
我添加了以下内容,问题已解决:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// 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
}
如果您有任何模块库,它也应该具有您的应用项目中提到的相同构建类型。
我也在库中添加了此 buildTypes,因为与您的应用中提到的类型相同。
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{}
uat{}
}
对我有用。
我已更新到 Android Studio 3.0.1,但我的控制台出现此错误:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :libraries:Jumble:generateDebugSources, :libraries:Jumble:generateDebugAndroidTestSources, :libraries:Jumble:mockableAndroidJar]
Error:Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve project :libraries:Jumble.
Required by:
project :app
> Cannot choose between the following configurations of project :libraries:Jumble:
- debugRuntimeElements
- releaseRuntimeElements
All of them match the consumer attributes:
- Configuration 'debugRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
- Configuration 'releaseRuntimeElements':
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' but no value provided.
- Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but wasn't required.
- Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
- Required org.gradle.api.attributes.Usage 'java-runtime' and found compatible value 'java-runtime'.
更新后出现此问题的原因是什么?
问题已解决!
我的应用程序在根文件夹中没有 build.gradle
文件。
我添加了以下内容,问题已解决:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// 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
}
如果您有任何模块库,它也应该具有您的应用项目中提到的相同构建类型。 我也在库中添加了此 buildTypes,因为与您的应用中提到的类型相同。
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug{}
uat{}
}
对我有用。