[Messaging] getToken() hangs infinitely and onNewToken() is never called when using Firebase BOM 34.12.0 with androidx.datastore 1.3.0-alpha07
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- mobile-dev
Hướng nghiên cứu
Tái hiện vấn đề với các phiên bản và dependency trong build.gradle.kts, sau đó theo dõi hành vi của FirebaseMessaging.getInstance().token và onNewToken() của MyFirebaseMessagingService.kt với Firebase BOM 34.12.0 và androidx.datastore 1.3.0-alpha07. So sánh với Datastore 1.3.0-alpha06 hoặc Firebase BOM 33.16.0; được xem là hoàn tất khi việc lấy token hoàn thành và onNewToken() được gọi với tổ hợp bị ảnh hưởng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[READ] Step 1: Are you in the right place?
Yes.
[REQUIRED] Step 2: Describe your environment
- Android Studio version: Android Studio Panda 4 | 2025.3.4 RC 1
- Firebase Component: firebase-messaging
- Component version: Firebase BOM 34.12.0 (Bug also depends on
androidx.datastore:1.3.0-alpha07)
[REQUIRED] Step 3: Describe the problem
I am using Firebase Cloud Messaging in my project, managed via the Firebase BOM. I also use androidx.datastore to store user preferences.
There seems to be a severe conflict or bug when combining recent versions of the Firebase BOM with the latest alpha version of Jetpack Datastore.
The Issue:
FirebaseMessagingService().onNewToken()is never called, not even on a fresh installation of the app.- When calling
FirebaseMessaging.getInstance().getToken(), the task runs infinitely and never completes (neither succeeds nor fails).
Version specific behavior:
- The bug occurs when using Firebase BOM 34.12.0 in combination with androidx.datastore 1.3.0-alpha07.
- If I downgrade
androidx.datastoreto 1.3.0-alpha06, the issue disappears and FCM works correctly. - Alternatively, if I keep Datastore at
1.3.0-alpha07but downgrade the Firebase BOM to 33.16.0, the issue also disappears.
This indicates a dependency clash between the newest Datastore alpha and the newest Firebase BOM, causing the FCM token generation/retrieval task to deadlock or silently fail.
The behavior can be reproduced in a fresh project.
Steps to reproduce:
- Create a project using Firebase BOM
34.12.0andfirebase-messaging. - Add
androidx.datastore:datastore-preferences:1.3.0-alpha07. - Set up a basic
FirebaseMessagingService. - Install the app fresh. Notice that
onNewToken()is missing. - Attempt to fetch the token manually via
FirebaseMessaging.getInstance().token. Notice that the listener is never triggered.
Relevant Code:
build.gradle.kts (Dependencies):
dependencies {
// Firebase
implementation(platform("com.google.firebase:firebase-bom:34.12.0"))
implementation("com.google.firebase:firebase-messaging")
// Datastore (Causes the FCM infinite hang with the BOM above)
implementation("androidx.datastore:datastore-preferences:1.3.0-alpha07")
// Note: Reverting to 1.3.0-alpha06 fixes the Firebase issue.
}
MyFirebaseMessagingService.kt:
import android.util.Log
import com.google.firebase.messaging.FirebaseMessagingService
class MyFirebaseMessagingService : FirebaseMessagingService() {
override fun onNewToken(token: String) {
super.onNewToken(token)
// BUG: This is NEVER called on fresh install when using the dependency combination above.
Log.d("FCM_TEST", "Refreshed token: $token")
}
}
MainActivity.kt (Manual Token Fetching):
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.messaging.FirebaseMessaging
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d("FCM_TEST", "Fetching FCM token...")
FirebaseMessaging.getInstance().token.addOnCompleteListener { task ->
// BUG: This callback is NEVER reached. It hangs infinitely.
if (!task.isSuccessful) {
Log.w("FCM_TEST", "Fetching FCM registration token failed", task.exception)
return@addOnCompleteListener
}
val token = task.result
Log.d("FCM_TEST", "FCM Token: $token")
}
}
}
- Ngôn ngữ chính
- Java
- Star
- 2.6k
- Fork
- 733
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 72
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/firebase-android-sdk
-
api: remoteconfig
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
firebase/firebase-android-sdk#8827 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Crashlytics plugin writes build ID lists in directory listing order, so APKs can differ between machinesCó thể đã có người làm @mrober đã nhận 8 ngày trước. Đang mởapi: crashlytics
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
firebase/firebase-android-sdk#8789 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
api: auth
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
firebase/firebase-android-sdk#8505 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
firebase/firebase-android-sdk#8835 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
firebase/firebase-android-sdk#8832 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của firebase/firebase-android-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
NationalSecurityAgency/ghidra#10220 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
RIS export splits an organization name containing “and” into multiple authorsCó thể đã có người làm @Gautam-aman đã nhận hôm nay. Đang mởstatus: needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
JabRef/jabref#17821 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
FailureContext.java rounds down thresholds in lastedAtLeast()Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày