使用CC组件化报错"Could not determine the dependencies of task ':xxxx:compileReleaseJavaWithJavac'."解决方案

错误详情:

 What went wrong:
Could not determine the dependencies of task ':baseres:compileReleaseJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':baseres:releaseCompileClasspath'.
   > Could not resolve project :baseutils.
     Required by:
         project :baseres
      > Unable to find a matching configuration of project :baseutils:
          - Configuration 'debugApiElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found incompatible value 'debug'.
              - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
          - Configuration 'debugBundleElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'release' but no value provided.
              - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
              - Required org.gradle.usage 'java-api' and found incompatible value 'android-bundle'.
          - Configuration 'debugMetadataElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found incompatible value 'debug'.
              - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Metadata'.
              - Required org.gradle.usage 'java-api' but no value provided.
          - Configuration 'debugRuntimeElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found incompatible value 'debug'.
              - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
              - Required org.gradle.usage 'java-api' and found incompatible value 'java-runtime'.
          - Configuration 'releaseApiElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
              - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
          - Configuration 'releaseBundleElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'release' but no value provided.
              - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but no value provided.
              - Required org.gradle.usage 'java-api' and found incompatible value 'android-bundle'.
          - Configuration 'releaseMetadataElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
              - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Metadata'.
              - Required org.gradle.usage 'java-api' but no value provided.
          - Configuration 'releaseRuntimeElements':
              - Required com.android.build.api.attributes.BuildTypeAttr 'release' and found compatible value 'release'.
              - Found com.android.build.api.attributes.VariantAttr 'release' but wasn't required.
              - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found incompatible value 'Apk'.
              - Required org.gradle.usage 'java-api' and found incompatible value 'java-runtime'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get f
ull insights.

错误原因分析及解决方式:

在组件化中,组件之间不相关依赖,即baseutils也是组件化Moudle,不能通过implementation project(':baseutils'),需要使用 addComponent 'baseutils'addComponent 'baseres', project(':baseres') // 这里参数2可以省略的方式进行组件依赖

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation rootProject.ext.dependencies["kotlin"]
    implementation rootProject.ext.dependencies["constraint_layout"]
    implementation rootProject.ext.dependencies["appcompat_v7"]
    testImplementation rootProject.ext.dependencies["junit"]
    androidTestImplementation rootProject.ext.dependencies["runner"]
    androidTestImplementation rootProject.ext.dependencies["espresso_core"]
    implementation rootProject.ext.dependencies["utilcode"]
//    implementation "com.android.support:appcompat-v7:27.1.1"
    //公用依赖包
//    addComponent 'baseutils'
    implementation project(':baseutils')
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值