NoSuchMethodError: DesugarCollections.synchronizedMap in release instrumentation tests with firebase-sessions 3.0.7 (BOM 34.x)

未关闭
#8,600 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
android, firebase, java

调研方向

从附加的 firebase-desugar-repro.zip 开始,使用列出的 release instrumentation-test 配置和 adb 命令复现崩溃。追踪主 APK 与测试 APK 之间相互冲突的 DesugarCollections 版本;当 release instrumentation test 在没有 NoSuchMethodError 的情况下启动时即表示完成。

由索引模型根据 Issue 内容生成。

描述

api: sessions

Running Instrumentation tests with minify enabled release builds after updating to the 34.x from 33.x results into a NoSuchMethodError crash as soon as we launch the app in test environment.

Environment
  • Firebase BOM: 34.18.0
  • firebase-sessions: 3.0.7
  • firebase-crashlytics: 20.1.1
  • AGP: 8.13.2
  • desugar_jdk_libs: 2.1.5 (latest public)
  • testBuildType: release
  • minifyEnabled: true
Steps to reproduce:
  1. Add firebase-crashlytics (or any lib that pulls in firebase-sessions) with BOM 34.x
  2. Set minifyEnabled true in release build type
  3. Set testBuildType "release" in android block
  4. Set coreLibraryDesugaringEnabled true with desugar_jdk_libs:2.1.5
  5. Run adb shell am instrument -w -r .test/androidx.test.runner.AndroidJUnitRunner

Expected: instrumentation test runs
Actual: process crashes immediately during FirebaseInitProvider.onCreate before any test runs -

java.lang.NoSuchMethodError: No static method synchronizedMap(Ljava/util/Map;)Ljava/util/Map;
in class Lj$/util/DesugarCollections; or its super classes
(declaration of 'j$.util.DesugarCollections' appears in <package>.test apk)
    at CrashlyticsRegistrar.<clinit>
    at FirebaseInitProvider.onCreate

firebase-sessions:3.0.7 calls DesugarCollections.synchronizedMap() which was compiled against an internal desugaring library that includes this method. In a normal release build this works because Firebase's bundled DesugarCollections (with synchronizedMap) is the only one present. In release instrumentation tests, the test APK brings its own DesugarCollections from the public desugar_jdk_libs:2.1.5 (which lacks synchronizedMap) and it shadows the main APK's version, causing the crash.

Relevant Code:

Attaching a minimal repro project to reproduce this issue.

firebase-desugar-repro.zip

主要语言
Java
星标
2.6k
派生
733
平均合并
2 天 15 小时
30 天内合并 PR
72

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/firebase-android-sdk 的其他 Issue

查看 firebase/firebase-android-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。