消费者被配置为查找与 Java 11 兼容的库的运行时,打包为 jar,及其在外部声明的依赖项,但是:

SeP*_*läm 13 android-studio build.gradle android-gradle-plugin

在升级应用程序使用的本机java库之一后,此错误消息开始阻止构建我的Flutter应用程序:

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)
Run Code Online (Sandbox Code Playgroud)

项目 build.gradle 文件包含(除其他外):

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'
}
Run Code Online (Sandbox Code Playgroud)

库的 aar 文件 ( mesh-release.aar) 存储在名为 的文件夹中mesh-release,该文件夹还包含一个具有以下内容的文件:

configurations.maybeCreate("default")
artifacts.add("default", file('mesh-release.aar'))
Run Code Online (Sandbox Code Playgroud)

您有什么想法如何解决这个问题吗?不幸的是,无法降级到以前使用的版本......

SeP*_*läm 6

我犯了一个错误,将本机库依赖项放入build.gradle文件中:

  1. android/build.gradle(原生库的gradle文件)
  2. example/android/build.gradle (使用该库的示例应用程序的 gradle 文件)从示例应用程序中删除依赖项后,问题消失了。

除此之外,distributionUrlatexample/android/gradle/wrapper/gradle-wrapper.properties已更新到最新版本。