当尝试在我的 Android 应用程序中实现 Firebase Firestore (com.google.firebase:firebase-firestore) 时,我收到 protobuf 版本与 Google Dialogflow (com.google.cloud:google-cloud-dialogflow:0.77.0-alpha) 的冲突。在排除任何依赖项之前我得到的第一个错误是:
Error: Program type already present: com.google.api.AuthProviderOrBuilder
Run Code Online (Sandbox Code Playgroud)
我已经缩小了发生的范围,因为 Firestore 使用以下依赖项:
com.google.protobuf:protobuf-lite:3.0.1
io.grpc:grpc-protobuf-lite:1.16.1
Run Code Online (Sandbox Code Playgroud)
Dialogflow 使用:
com.google.protobuf:protobuf-java-util:3.6.1
com.google.protobuf:protobuf-java:3.6.1
io.grpc:grpc-protobuf:1.16.1
Run Code Online (Sandbox Code Playgroud)
排除任一版本都会导致 protobuf-java 的编译器错误(其中缺少类但没有依赖项)或以下函数中的应用程序崩溃,并出现以下错误:
db.collection("users")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
// For every document within the specified collection
for (QueryDocumentSnapshot document : task.getResult()) {
Log.d(TAG, document.getId() + " => " + document.getData());
}
} else {
Log.w(TAG, "Error getting documents.", task.getException());
}
} …Run Code Online (Sandbox Code Playgroud) android protocol-buffers firebase google-cloud-firestore dialogflow-es