firebase-auth calls ContextCompat.registerReceiver(Context, BroadcastReceiver, IntentFilter, int) but declares no androidx.core dependency
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 领域
- build-system, mobile
调研方向
首先定位 firebase-auth Gradle 依赖声明,并使用 dependencyInsight 和所述的 phone-auth 调用,在精简的依赖关系图下重现该问题。当依赖关系图能保证 androidx.core 至少为 1.9.0,且 SMS retriever 不再因报告的 NoSuchMethodError 失败时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
[REQUIRED] Step 2: Describe your environment
- Android Studio version: n/a — Gradle build, AGP 8.12.0 / Gradle 8.14.3
- Firebase Component: Auth
- Component version: 23.2.1 (via firebase-bom 33.15.0); also verified against 24.2.0
[REQUIRED] Step 3: Describe the problem
firebase-auth calls ContextCompat.registerReceiver(Context, BroadcastReceiver, IntentFilter, int) when it sets up the SMS retriever for phone auth. That overload was added in androidx.core 1.9.0.
firebase-auth does not declare a dependency on androidx.core at any version. Its POM declares:
androidx.browser:browser:1.4.0
androidx.collection:collection:1.0.0
androidx.credentials:credentials:1.2.0-rc01
androidx.credentials:credentials-play-services-auth:1.2.0-rc01
androidx.fragment:fragment:1.1.0
androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
androidx.fragment:1.1.0 is far too old to pull in a suitable androidx.core, so nothing in the declared graph guarantees the method exists. The highest androidx.core reachable from firebase-auth alone is 1.2.0, via play-services-base:18.0.1 / play-services-basement:18.4.0.
The result is that any consumer whose dependency graph does not otherwise contain androidx.core >= 1.9.0 gets a hard crash on the first phone auth call.
This is masked for most apps, because appcompat, activity, Compose and core-ktx all bring androidx.core 1.13–1.19 and conflict resolution picks those. It is not masked for consumers with a lean graph — in our case an instrumented-test APK for a library that wraps the Firebase SDKs, which depends on firebase-auth and androidx.test but not on any UI artifact.
Steps to reproduce:
- Create an Android module that depends on
com.google.firebase:firebase-authwithoutappcompat,activity, Compose, orcore-ktx. - Confirm the resolved version is old —
./gradlew :module:dependencyInsight --configuration debugRuntimeClasspath --dependency androidx.core:corereportsandroidx.core:core:1.2.0, selection reasonBy conflict resolution: between versions 1.2.0, 1.1.0 and 1.0.0. - Call
PhoneAuthProvider.verifyPhoneNumber(...). - It crashes as soon as the SMS retriever is registered.
Verified that androidx.core:core:1.9.0 contains the overload and 1.2.0 does not, by decompiling both:
$ javap -classpath <core-1.9.0> androidx.core.content.ContextCompat | grep registerReceiver
public static android.content.Intent registerReceiver(android.content.Context, android.content.BroadcastReceiver, android.content.IntentFilter, int);
public static android.content.Intent registerReceiver(android.content.Context, android.content.BroadcastReceiver, android.content.IntentFilter, java.lang.String, android.os.Handler, int);
$ javap -classpath <core-1.2.0> androidx.core.content.ContextCompat | grep registerReceiver
(no such overload)
Relevant Code:
java.lang.NoSuchMethodError: No static method registerReceiver(Landroid/content/Context;Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;I)Landroid/content/Intent;
in class Landroidx/core/content/ContextCompat; or its super classes
(declaration of 'androidx.core.content.ContextCompat' appears in /data/app/~~-GawQ-mLA-xVH6tujzcrdw==/dev.gitlive.firebase.auth.test-YTNifziXwZqfmlaaSKp6KQ==/base.apk)
at com.google.android.gms.internal.firebase-auth-api.zzafu.zza(com.google.firebase:firebase-auth@@23.2.1:115)
at com.google.android.gms.internal.firebase-auth-api.zzaef.zza(com.google.firebase:firebase-auth@@23.2.1:148)
at com.google.android.gms.internal.firebase-auth-api.zzaee.zza(com.google.firebase:firebase-auth@@23.2.1:9)
at com.google.android.gms.internal.firebase-auth-api.zzafj.run(com.google.firebase:firebase-auth@@23.2.1:3)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at com.google.firebase.concurrent.CustomThreadFactory.lambda$newThread$0$com-google-firebase-concurrent-CustomThreadFactory(CustomThreadFactory.java:47)
at com.google.firebase.concurrent.CustomThreadFactory$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
at java.lang.Thread.run(Thread.java:1012)
Suggested fix
Have firebase-auth declare the minimum androidx.core its code actually requires, either as a dependency or as a constraint:
api("androidx.core:core:1.9.0")
1.9.0 is the exact floor for the overload in use. Declaring it would let Gradle's conflict resolution do the right thing for lean consumers, while apps that already bring a newer androidx.core are unaffected.
We have worked around it locally by pinning androidx.core on the affected test source set, so this is not blocking us — filing because the underdeclaration looks unintentional and still applies in 24.2.0.
- 主要语言
- Java
- 星标
- 2.6k
- 派生
- 733
- 平均合并
- 2 天 15 小时
- 30 天内合并 PR
- 72
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/firebase-android-sdk 的其他 Issue
-
api: remoteconfig
难度 2/5 1-3 小时 新手友好度 78/100
firebase/firebase-android-sdk#8827 ·
维护者通常 1 天内回复
-
Crashlytics plugin writes build ID lists in directory listing order, so APKs can differ between machines可能已有人在做 @mrober 于 8 天前认领。 未关闭api: crashlytics
难度 2/5 1-3 小时 新手友好度 72/100
firebase/firebase-android-sdk#8789 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 15/100
firebase/firebase-android-sdk#8835 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 25/100
firebase/firebase-android-sdk#8832 ·
维护者通常 1 天内回复
-
Firestore: NoSuchElementException in SQLiteIndexManager.encodeValues for a != query with a trailing orderBy when cache index auto-creation is enabled可能已有人在做 @dconeybe 于 2 天前认领。 未关闭api: firestore
firebase/firebase-android-sdk#8831 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 firebase/firebase-android-sdk 的全部 Issue
相似的 Issue
-
good first issue
难度 2/5 1-3 小时 新手友好度 65/100
commons-app/apps-android-commons#7341 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
NationalSecurityAgency/ghidra#10220 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复