我迁移到 Android Studio 3.0。因此,项目无法编译名为“:animator”的模块,并显示此错误:
Error:Unable to resolve dependency for ':app@dexOptions/compileClasspath': Could not resolve project :animators. <a href="openFile:/home/mobilepowered/MobilePowered/MyInnovalee/trunk17-10-2017/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for ':app@dexOptions/compileClasspath': Could not resolve project :animators.">Show Details</a>
并显示详细信息给出了这个日志:
Unable to resolve dependency for ':app@dexOptions/compileClasspath': Could not resolve project :animators. Could not resolve project :animators. Required by: project :app Unable to find a matching configuration of project :animators: - Configuration 'debugApiElements': - Required com.android.build.api.attributes.BuildTypeAttr 'dexOptions' and found incompatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'. - Configuration 'debugRuntimeElements': - Required com.android.build.api.attributes.BuildTypeAttr 'dexOptions' and found incompatible value 'debug'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'. - Configuration 'releaseApiElements': - Required com.android.build.api.attributes.BuildTypeAttr 'dexOptions' and found incompatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found compatible value 'java-api'. - Configuration 'releaseRuntimeElements': - Required com.android.build.api.attributes.BuildTypeAttr 'dexOptions' and found incompatible value 'release'. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required. - Required org.gradle.api.attributes.Usage 'java-api' and found incompatible value 'java-runtime'.
使用 Android Studio 2.3(AS) 项目工作正常,我可以运行应用程序。将 AS 更新到 Android Studio 3.0 后。对于库和构建类型,我也遇到了如下错误。
Unable to resolve dependency for ':app@dexOptions/compileClasspath': Could not resolve project : library_Name. Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve project : library_Name.
解决问题,简单。
曾经是什么
buildTypes{ debug{ ... } release{ ... } }
你在你的 (应用程序)build.gradle 文件中,你必须包括所有buildTypes{ }同名的
buildTypes{ }
放入 项目中包含的所有库/模块*build.gradle的文件中。 *
build.gradle
清理并重建项目,问题将得到解决。
问题仍未解决,请将 gradle-wrapper.properties 更新为
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip