提问人:gbryant 提问时间:10/28/2023 更新时间:10/28/2023 访问量:28
升级后 Flutter 库/工具版本不匹配
Flutter library/tool version mismatch after upgrading
问:
我们正在做一个几乎没有代码更改的版本,但已经有几个月了,所以很多被弃用的库版本触发了相当大的库更新,这从来都不是好事,所以我们试图将这些更改保持在最低限度。
我的 Mac 上的 VSCode、Gradle 和 Android Gradle 插件版本之间的某些东西现在不同步,我无法解开他们想要什么。
flutter build apk 不会产生非常丰富的错误,所以我下拉到:
$ ./gradlew assembleDebug --scan
忽略绒毛,告诉我这个:
A problem occurred configuring project ':purchases_flutter'.
> Could not resolve all files for configuration ':purchases_flutter:classpath'.
> Could not resolve com.android.tools.build:gradle:8.0.2.
Required by:
project :purchases_flutter
> No matching variant of com.android.tools.build:gradle:8.0.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.6.1' but:
- Variant 'apiElements' capability com.android.tools.build:gradle:8.0.2 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
- Variant 'javadocElements' capability com.android.tools.build:gradle:8.0.2 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 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
- Variant 'runtimeElements' capability com.android.tools.build:gradle:8.0.2 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
- Variant 'sourcesElements' capability com.android.tools.build:gradle:8.0.2 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 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.6.1')
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':purchases_flutter' of type org.gradle.api.Project.
> Could not get unknown property 'android' for project ':purchases_flutter' of type org.gradle.api.Project.
颤动医生很高兴:
[✓] Flutter (Channel stable, 3.13.6, on macOS 13.5.2 22G91 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Android Studio (version 2022.3)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.82.2)
我已经清除了pub_cache并重新拉取了所有库。pubspec.yaml 的相关位是:
environment:
sdk: '>=3.0.6 <4.0.0'
dependencies:
[snip]
flutter:
sdk: flutter
purchases_flutter: ^6.1.0
build.gradle 的 buildscript 部分:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
}
}
我的gradle-wrapper.properties文件有指向7.6.1的distributionUrl。(由 gradlew 自动生成)
除了 VSCode 本身之外,我没有看到任何其他引用 gradle 版本的内容,Gradle for Java 插件是 v3.13.3,而我当前的 Java 版本是 1.8.0_221。
我尝试过的: 实际上,我已经忘记了很多,但是我已经尝试了将主应用程序的build.gradle依赖项中的版本更改为8.0.2的明显部分,但是我遇到了同样的错误。如果我查看 /Library/Users/me/.gradle/caches,如果这意味着什么,就会有一个 8.0.2 文件夹。
我怀疑问题实际上是purchases_flutter库,更有可能是本地环境中的东西。
答: 暂无答案
评论