依赖项升级后 Android Firebase 依赖项出现颤振问题
Posted
技术标签:
【中文标题】依赖项升级后 Android Firebase 依赖项出现颤振问题【英文标题】:Flutter issues with Android Firebase dependencies after Dependency Upgrades 【发布时间】:2021-05-01 20:39:54 【问题描述】:我最近决定根据 pub.dev 将我的 Flutter 依赖项和 pubspec.yaml 全部升级到最新版本。
由于我主要使用 ios 进行测试,所以我很晚才意识到,我的 android 版本不再工作了。不幸的是,错误消息的直接信息非常低。
Gradle sync failed: Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Problems reading data from Binary store in /private/var/folders/mw/s9362rr10qv43x_yh6qgm17w0000gn/T/gradle8805841490318013448.bin offset 286370 exists? true
Consult IDE log for more details (Help | Show Log) (25 s 303 ms)
然而,我决定也为我的 android studio 提供 4.1 的更新,并升级了 gradle 依赖项。
dependencies
classpath 'com.android.tools.build:gradle:4.1.2' // 3.5.1
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4' // 4.3.3
android studio 中的新尝试提供了一个与 Firebase 相关的更相关的错误
Gradle sync failed: Problems reading data from Binary store in /private/var/folders/mw/s9362rr10qv43x_yh6qgm17w0000gn/T/gradle1329056569736096566.bin offset 296201 exists? true
Corrupt serialized resolution result. Cannot find selected module (224) for constraint platform-runtime -> com.google.firebase:firebase-iid:21.0.1
Consult IDE log for more details (Help | Show Log) (10 m 18 s 294 ms)
我的 Flutter Doctor -v 让我相信一切都很好。 (插件错误是 Flutter 团队在 Android Studio 4.1 中存在的已知问题,与此无关)
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.1 20C69 darwin-x64, locale de-DE)
• Flutter version 1.22.6 at /Users/kaibaier/development/flutter
• Framework revision 9b2d32b605 (5 days ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/kaibaier/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = /Users/kaibaier/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.9.3
[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1
[✓] Connected device (1 available)
• Redmi Note 8 (mobile) • 18d3ce30 • android-arm64 • Android 10 (API 29)
为了完成,我还添加了 pubspec.yaml 依赖项和以前使用的版本。您会注意到 Firebase 和 Google 地图中的大版本跳跃
dependencies:
flutter:
sdk: flutter
permission_handler: ^5.0.1+1
cupertino_icons: ^1.0.0 #^0.1.3
firebase_core: ^0.7.0 # ^0.5.0
firebase_auth: ^0.20.0+1 # ^0.18.0+1
firebase_storage: ^7.0.0 # ^4.0.0
cloud_firestore: ^0.16.0 #^0.14.0+2
provider: ^4.3.3 #^4.3.2
flutter_spinkit: ^4.1.2+1
flutter_vector_icons: ^0.2.1
intl: ^0.16.1
image_cropper: ^1.3.1
image_picker: ^0.6.7+21 #^0.6.7+11
searchable_dropdown: ^1.1.3
flutter_colorpicker: ^0.3.5 #^0.3.4
flutter_masked_text: ^0.8.0
shared_preferences: ^0.5.12+4 #^0.5.8
path_provider: ^1.6.27 #^1.6.11
location: ^3.2.4 #^3.0.2
table_calendar: ^2.3.3 #^2.2.3
url_launcher: ^5.7.10 #^5.6.0
google_maps_flutter: ^1.1.1 #^0.5.32
flutter_google_places: ^0.2.6
http: ^0.12.2 #^0.12.1
uuid: ^2.2.2 #^2.0.4
flutter_appcenter_bundle: ^3.2.0+2
preload_page_view: ^0.1.4
device_preview: ^0.5.5 #^0.4.8
wakelock: ^0.2.1+1 #^0.1.4+2
非常欢迎任何帮助/想法或想法:)
更新: 尝试在我的 android 手机上再次运行测试后,我遇到了另一个相关错误。
Note: /Users/kaibaier/development/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.7.0/android/src/main/java/io/flutter/plugins/firebase/core/FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Problems reading data from Binary store in /private/var/folders/mw/s9362rr10qv43x_yh6qgm17w0000gn/T/gradle3299415366350440389.bin offset 0 exists? true
* 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 full insights.
更新#2: 我还在 GitHub 上发布了这个问题 https://github.com/FirebaseExtended/flutterfire/issues/4848
更新#3: 好的,我能够弄清楚这个文件:/private/var/folders/mw/s9362rr10qv43x_yh6qgm17w0000gn/T/gradle3299415366350440389.bin 仅在构建阶段存在。错误抛出后,直接又没了。
更新#4: 我现在回滚到旧的 firebase 依赖项。刚刚升级了 Firebase 存储。经过一些豆荚和 Grasflecks 清洁后,一切运行顺利。 我的问题仍然存在,因为我希望回到新版本的 firebase dependencies 。但现在我可以重新构建。
【问题讨论】:
你有没有尝试清理 gradle 文件 ./gradlew clean 您好,刚刚尝试的错误仍然是损坏的序列化解析结果。找不到约束平台运行时的选定模块 (212) -> com.google.firebase:firebase-iid:21.0.1 对于 ios 尝试做:pod deintegrate
、pod cache clean --all
和 rm Podfile.lock
iOS 运行良好
能告诉我gradle版本和java版本吗?
【参考方案1】:
Firebase 升级后我遇到了完全相同的问题。除了 pubspec.yaml 之外,您还需要在 app/build.gradle 中升级另一个(有些隐藏的)依赖项。我将我的从 17.x 更改为 this 以及所有构建和运行。
实施 'com.google.firebase:firebase-analytics:18.0.2'
【讨论】:
以上是关于依赖项升级后 Android Firebase 依赖项出现颤振问题的主要内容,如果未能解决你的问题,请参考以下文章
将 Android Studio 的 Gradle 插件升级到 3.0.1 和 Gradle 到 4.1 后无法复制配置依赖项
Firebase android:更新依赖项后的Multidex错误