“Error:Cannot choose between the following configurations of project”

时间:2021-7-21 作者:qvyue

加载编译时,提示“Error:Cannot choose between the following configurations of project”错误,记录下解决方案省的忘记了:

  • 具体报错信息:
    Error:Cannot choose between the following configurations of project :XXX:

    • debugApiElements
    • debugRuntimeElements
    • releaseApiElements
    • releaseRuntimeElements
      All of them match the consumer attributes:
    • Configuration ‘debugApiElements’:
      • Found com.android.build.api.attributes.BuildTypeAttr ‘debug’ but wasn’t required.
      • 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.
      • Found org.gradle.api.attributes.Usage ‘java-api’ but wasn’t required.
    • Configuration ‘debugRuntimeElements’:
      • Found com.android.build.api.attributes.BuildTypeAttr ‘debug’ but wasn’t required.
      • 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.
      • Found org.gradle.api.attributes.Usage ‘java-runtime’ but wasn’t required.
    • Configuration ‘releaseApiElements’:
      • Found com.android.build.api.attributes.BuildTypeAttr ‘release’ but wasn’t required.
      • 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.
      • Found org.gradle.api.attributes.Usage ‘java-api’ but wasn’t required.
    • Configuration ‘releaseRuntimeElements’:
      • Found com.android.build.api.attributes.BuildTypeAttr ‘release’ but wasn’t required.
      • 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.
      • Found org.gradle.api.attributes.Usage ‘java-runtime’ but wasn’t required.
  • 解决方案:
    1、 project的 build.gradle文件,删除“ apt”配置:
    classpath ‘com.neenbedankt.gradle.plugins:android-apt:1.8’ //删除
    2、 module的 build.gradle文件,删除“android-apt”引用:
    apply plugin: ‘android-apt’ //删除
    3、 module的 build.gradle文件,修改“dependencies”中的“apt”方式 为“annotationProcessor”方式:
    apt “引用项” //老方式,删除
    annotationProcessor “引用项” //新方式

声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:qvyue@qq.com 进行举报,并提供相关证据,工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。