Android Studio 3.0:无法解析依赖项:对于:app @ dexOptions / compileClasspath',无法解析项目:animators。

175

我迁移到了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
 &#39;:app@dexOptions/compileClasspath&#39;: 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'.

你做了什么? - Pandiri Deepak
作为使项目在Android Studio 3.0中运行的第一个临时解决方案,我维护 distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zipcompileSdkVersion 25buildToolsVersion "25.0.3" 以及 **classpath 'com.android.tools.build:gradle:2.3.3'**。 - Imene Noomene
@ImeneNoomene,应该选择JackHuang的答案。它基于官方文档,而Sackurise所说的并不总是可行的(想想React Native项目,其中大多数模块都来自Web)。 - Leo supports Monica Cellio
我遇到了由于多种口味库而引起的这个问题。解决方案来自: https://dev59.com/qGAf5IYBdhLWcg3wQQu4#48718124 - Yeung
我通过简单地更新“Android Studio”解决了我的问题。 - Frank Goortani
32个回答

-1
Step 1:
1.Open the Preferences, by clicking File > Settings (on Mac, Android Studio > Preferences).
2.In the left pane, click Build, Execution, Deployment >> Gradle.
3.Uncheck/disable the Offline work checkbox.
4.Click Apply or OK.

Step 2:
downgrade the gradle-wrapper.properties content which you can access this 
file directory by clicking on CTRL + SHFT +R KEY 
e.g from
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

to 
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip

or to any lower version like /gradle-3.9-all.zip or /gradle-3.8-all.zip

-3

尝试这个,我已经通过注释下面的行来解决了我的问题

依赖项

{

compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
//compileOnly 'com.android.support.test:runner:1.0.1'
//compileOnly 'com.android.support.test.espresso:espresso-core:3.0.1'
//androidTestImplementation 'junit:junit:4.12'

}


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接