firebase / firebase/firebase-admin-java

Class Conflict between two Firebase modules.

未关闭
#891 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
needs-triage
主要语言
Java
星标
620
派生
305
平均合并
3 小时 23 分钟
30 天内合并 PR
1

描述

### Environment
This is currently the dependencies used in my app-level Gradle build script
```kotlin
dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.navigation:navigation-fragment:2.7.5")
implementation("androidx.navigation:navigation-ui:2.7.5")

implementation("com.squareup.retrofit2:converter-gson:2.9.0")
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")

implementation("com.google.firebase:firebase-admin:9.2.0")
implementation("com.google.firebase:firebase-messaging:23.4.0")
}
```

### Description
**TL;DR**: `firebase-admin` and `firebase-messaging` has the same classpath `com.google.firebase.messaging.*`, but their class's content is totally different.

Currently, I want to use both the module `firebase-admin` and `firebase-messaging` to learn about the feature Cloud Messaging, so I have installed my dependencies as above. The issue arose when I wanted to import the class `FirebaseMessaging`.

```java
// Create a list containing up to 500 registration tokens.
// These registration tokens come from the client FCM SDKs.
List registrationTokens = Arrays.asList(
"YOUR_REGISTRATION_TOKEN_1",
// ...
"YOUR_REGISTRATION_TOKEN_n"
);

MulticastMessage message = MulticastMessage.builder()
.putData("score", "850")
.putData("time", "2:45")
.addAllTokens(registrationTokens)
.build();
BatchResponse response = FirebaseMessaging.getInstance().sendMulticast(message);
// See the BatchResponse reference documentation
// for the contents of response.
System.out.println(response.getSuccessCount() + " messages were sent successfully");
```

While I was following [this tutorial] (https://firebase.google.com/docs/cloud-messaging/send-message#send-messages-to-multiple-devices) to build a send request to multiple devices, my IDE could not resolve the method `sendMutlicast()`

It turned out that while the imported class was `com.google.firebase.messaging.FirebaseMessaging`, the class was from the module `firebase-messaging` , which did not contain any of useful `send` method, rather than `firebase-admin`.

Is there anyway I can import the class `FirebaseMessaging` from `firebase-admin` and still keeping the two modules? I had switching the import order in Gradle file but still to no avail.

Thank you very much!

贡献指南

打开贡献指南

调研方向

从 issue 中显示的应用级 Gradle 依赖项开始,并将 firebase-admin 和 firebase-messaging artifact 与链接的 Cloud Messaging 教程进行比较。确定两个模块是否可以在不出现重复的 com.google.firebase.messaging 包的情况下共存;完成的标准是,有一份记录在案的依赖配置能够解析 FirebaseMessaging,并提供教程中的 sendMulticast API。

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

评估

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

把新 issue 发到你的邮箱

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