简体   繁体   English

带有gRPC构建错误的Cloud Firestore

[英]Cloud Firestore with gRPC build error

I'm working on an android application, which have to use gRPC and Firestore. 我正在使用必须使用gRPC和Firestore的android应用程序。 However, when I added both one of module from 'io.grpc' group dependency (eg io.grpc:grpc-okhttp:1.7.0) and firestore dependency (com.google.firebase:firebase-firestore:11.4.2) in the build gradle config, I got a build error “Unable to merge dex”. 但是,当我在“ io.grpc”组依赖项(例如io.grpc:grpc-okhttp:1.7.0)和firestore依赖项(com.google.firebase:firebase-firestore:11.4.2)中添加模块之一时,构建gradle配置时,出现构建错误“无法合并dex”。 After with 'stacktrace' build option, I saw that the problem is 使用“ stacktrace”构建选项后,我看到了问题是

Multiple dex files define Lio/grpc/internal/OobChannel$5;

It could happen if firestore uses grpc-core module, but there is no one similar in tree dependencies, which I got using [androidDependencies] gradle task. 如果firestore使用grpc-core模块,可能会发生这种情况,但是树依赖项中没有类似的东西,这是我使用[androidDependencies] gradle任务得到的。 I tried to exclude io.grpc like this: 我试图像这样排除io.grpc:

implementation ('com.google.firebase:firebase-firestore:11.4.2') {
    exclude group: 'io.grpc'
}

but there was the same error. 但是有同样的错误。 Then I thought what if I exclude all 'io.grpc.' 然后我想如果我排除所有“ io.grpc”怎么办。 transitive dependencies from grpc module dependencies with adding grpc-core for internal classes. grpc模块依赖项的传递依赖项,并为内部类添加grpc-core。 In this way, I wrote ugly dependencies just for test 这样,我写了丑陋的依赖只是为了测试

implementation 'com.google.firebase:firebase-firestore:11.4.2'
implementation('io.grpc:grpc-okhttp:1.7.0') {
    exclude group: 'io.grpc'
}
implementation('io.grpc:grpc-protobuf-lite:1.7.0') {
    exclude group: 'io.grpc'
}
implementation('io.grpc:grpc-stub:1.7.0') {
    exclude group: 'io.grpc'
}
implementation 'io.grpc:grpc-core:1.7.0'

I was surprised when it successfully compiled, but after launch app, it crashed with java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev) 它成功编译时让我感到惊讶,但是启动应用程序后,它崩溃了,并出现java.lang.RuntimeException:Firestore中的内部错误(0.6.6-dev)

Caused by: java.lang.NoSuchMethodError: No static method zzcyc()Lio/grpc/ManagedChannelProvider; in class Lio/grpc/ManagedChannelProvider; or its super classes (declaration of 'io.grpc.ManagedChannelProvider' appears in /data/app/com.zipr.test-2/split_lib_dependencies_apk.apk)

I use gradle 3.0.0-rc1 with enabling multidex support. 我使用gradle 3.0.0-rc1启用了multidex支持。 I deleted .gradle, build directories, cleaned rebuilt project, but I still have build error. 我删除了.gradle,构建目录,清理了重建的项目,但是仍然有构建错误。 What can I do to resolve this problem? 我该怎么做才能解决这个问题?

Due to a variety of factors that constrain the way we build Android SDKs at Google, Firestore proguards a copy of gRPC within itself. 由于多种因素限制了我们在Google上构建Android SDK的方式,Firestore会在自己内部保护gRPC的副本。 Unfortunately this is leaky and you're running into the fallout: the 11.4.2 Firestore SDK is incompatible with any external gRPC :-(. 不幸的是,这是泄漏的,您正陷入后果:11.4.2 Firestore SDK与任何外部gRPC :-(不兼容。

This is essentially our top issue for the Firestore Android SDK and I'm sorry you've run into it. 从本质上讲,这是我们针对Firestore Android SDK的首要问题,很抱歉您遇到了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM