Home > database >  Could not determine the dependencies of task ':app:lintVitalRelease'. Can't generate
Could not determine the dependencies of task ':app:lintVitalRelease'. Can't generate

Time:09-30

Recently I added some kotlin activities and a library project to current java project. I can run project without any problem. clean - build - rebuild - run all are ok.

the problem appears when generating signed APK. I get below error:

Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:buildCompileClasspath'.
   > Could not resolve project :my_library.
     Required by:
         project :app
      > No matching variant of project :my_library was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'build', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
          - Variant 'debugApiElements' capability My_project:my_library:unspecified declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'build'
          - Variant 'debugRuntimeElements' capability My_project:my_library:unspecified declares a runtime of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'build'
          - Variant 'debugTestApiElements' capability My_project:my_library:unspecified declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debugTest' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'build'
          - Variant 'debugTestRuntimeElements' capability My_project:my_library:unspecified declares a runtime of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debugTest' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'build'
          - Variant 'releaseApiElements' capability My_project:my_library:unspecified declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'build'
          - Variant 'releaseRuntimeElements' capability My_project:my_library:unspecified declares a runtime of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'build'


gradle file in project level :

    buildscript {
    ext.kotlin_version = '1.5.0'
    ext {
        projectMinSdkVersion = 16      // 15 android 4.0.3 for release
        projectTargetSdkVersion = 30   //23 requires permission requests , 22 for release
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.3'
//        classpath 'com.android.tools.build:gradle:4.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//        classpath 'com.google.gms:google-services:4.3.4'//
        classpath 'com.google.gms:google-services:4.3.10'//
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1' //
    }

}
//plugins {
//    id 'nebula.lint' version '9.3.4'
//}
allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
//        maven {
  //          url "https://maven.google.com" // Google's Maven repository
    //    }
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:deprecation"
        }

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

plugins in library level:

    apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

plugins in app level:

    apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Any Idea?

CodePudding user response:

I found the solution, thanks to @Fabio. The problem was in buildTypes structure. so, in app level I have release and build, but in library level I have release and debug.

I changed buildTypes in library level like this to be same like in app level:

buildTypes {
    release {
        // minifyEnabled false
        // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

    build {
        //   minifyEnabled false
        //   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

so, I would recommend to copy it from app level and comment lines inside each build if required.

  • Related