firebase-auth publishes @UnknownInitialization but does not declare checker-qual, breaking Kotlin consumers

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃

调研方向

检查已发布的 firebase-auth-24.2.0 AAR 中的 classes.jar 和 POM,然后追踪生成这些元数据的 firebase-auth 依赖声明。使用报告中的 IdTokenListener lambda 重现 Kotlin 类型推断失败,并验证不使用 compileOnly checker-qual workaround 时干净的 consumer build 能够成功。

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

描述

api: auth type: bug
[READ] Step 1: Are you in the right place?

Yes — this is a defect in the published com.google.firebase:firebase-auth artifact metadata.

[REQUIRED] Step 2: Describe your environment
  • Android Studio version: n/a (Gradle CLI)
  • Firebase Component: Authentication (com.google.firebase:firebase-auth:24.2.0, via firebase-bom:34.18.0)
  • Component version: 24.2.0
  • Kotlin: 2.4.10 · AGP: 9.4.0-rc01 · Gradle: 9.7.1 · JDK 21
[REQUIRED] Step 3: Describe the problem

firebase-auth publishes classes annotated with org.checkerframework.checker.initialization.qual.UnknownInitialization, but its POM does not declare org.checkerframework:checker-qual. Consumers therefore have no way to resolve that annotation, and any Kotlin code that compiles against the annotated API and lets a type be inferred fails to compile.

Confirmed by scanning the artifact contents — the annotation reference is inside firebase-auth itself, not a transitive dependency:

$ unzip -p firebase-auth-24.2.0.aar classes.jar | strings | grep UnknownInitialization
# present in 24.2.0 and 24.1.0

and it is absent from the published POM (all 17 declared dependencies checked; androidx.*, play-services-*, firebase-*, kotlin-stdlib — no checker-qual).

Nothing else on the compile classpath supplies it either. firebase-auth pulls only the com.google.guava:listenablefuture stub, not full Guava — and full Guava is what historically put checker-qual on the classpath transitively. That is presumably why this was latent: the annotation is present in 24.1.0 as well, so an unrelated dependency change is what removed the accidental path to it.

Steps to reproduce:

Compile Kotlin against FirebaseAuth.IdTokenListener with an inferred lambda parameter, with checker-qual absent from the classpath:

FirebaseAuth.IdTokenListener { auth ->   // `auth` type inferred
  // ...
}

Relevant Code / error:

Type annotation class 'org.checkerframework.checker.initialization.qual.UnknownInitialization'
of the inferred type is inaccessible. Check the module classpath for missing or conflicting dependencies.

This reproduces through the official Flutter plugin (firebase_auth 6.6.0), whose IdTokenChannelStreamHandler.kt:23 is exactly that shape — :firebase_auth:compileDebugKotlin fails outright.

Note javac tolerates this (the JLS says unresolvable annotations are ignored), so Java consumers do not notice; Kotlin needs the annotation to resolve the inferred type, so only Kotlin consumers break.

Workaround (in a consumer's build, for anyone finding this):

dependencies { compileOnly("org.checkerframework:checker-qual:3.49.5") }

Suggested fix: declare checker-qual in firebase-auth's POM so it lands on consumers' compile classpath, or strip the annotation from the published class files if it is not meant to be part of the public API surface.

主要语言
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 摘要。