12

This error message started to prevent building my Flutter app after upgrading one of the native java libraries used by the app:

A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve androidx.room:room-runtime:2.3.0-rc01.
     Required by:
         project : > no.nordicsemi.android:mesh:3.1.5
      > No matching variant of androidx.room:room-runtime:2.3.0-rc01 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally but:
          - Variant 'releaseApiPublication' capability androidx.room:room-runtime:2.3.0-rc01 declares a library, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component, with the library elements 'aar' and the consumer needed a runtime of a component, packaged as a jar
              - Other compatible attribute:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
          - Variant 'releaseRuntimePublication' capability androidx.room:room-runtime:2.3.0-rc01 declares a runtime of a library, and its dependencies declared externally:
              - Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, packaged as a jar
              - Other compatible attribute:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
          - Variant 'sourcesElements' capability androidx.room:room-runtime:2.3.0-rc01 declares a runtime of a component, and its dependencies declared externally:
              - Incompatible because this component declares documentation and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about its target Java version (required compatibility with Java 11)
                  - Doesn't say anything about its elements (required them packaged as a jar)

The projects build.gradle file contains (amongst others):

dependencies {
    implementation fileTree(dir: 'mesh-release', include:['*.aar'])

    implementation 'no.nordicsemi.android:mesh:3.1.5'

    implementation 'androidx.room:room-runtime:2.3.0-rc01'
    annotationProcessor 'androidx.room:room-compiler:2.3.0-rc01'
    androidTestImplementation 'androidx.room:room-testing:2.3.0-rc01'
}

The library's aar file (mesh-release.aar) is stored in a folder named mesh-release which also contains a file with the following content:

configurations.maybeCreate("default")
artifacts.add("default", file('mesh-release.aar'))

Do you have any ideas how to fix that? Downgrading to the previously used version is unfortunately not an option...

SePröbläm
  • 5,142
  • 6
  • 31
  • 45

1 Answers1

5

I've made the mistake to put the native library dependencies into the build.gradle files at:

  1. android/build.gradle (gradle file of the native library)
  2. example/android/build.gradle (gradle file of the example application which uses the library) The problem disappeared after removing the dependencies from the example application.

Beside that, distributionUrl at example/android/gradle/wrapper/gradle-wrapper.properties got updated to the most recent version.

SePröbläm
  • 5,142
  • 6
  • 31
  • 45