问题
Recently I've been working on integrating a GRPC API in a size sensitive android app. The API only had a couple of Unary calls. I noticed that the resulting APK had io.grpc
(613KB) & io.opencensus
(178.9KB) which was further reduced to 387.2KB and 39.4KB respectively using Proguard. I noticed that Proguard was able to remove many streaming call related classes/methods from the APK. However, I noticed that the app already had com.google.protobuf
package, which I suspect is from something like Firebase SDK.
If Firebase SDK imported com.google.protobuf
, why didn't it need io.grpc
for transport? Does it use something else?
回答1:
The protobuf protocol is used by some Firebase SDKs as part of their internal communications. The first one that comes to mind is Firebase Analytics, but there are others too.
The Cloud Firestore SDK in Firebase uses grpc as part of its transport protocol. If you're not using Cloud Firestore then the grpc library will not be included as far as I know.
To ensure that unused methods are removed, be sure to use ProGuard as part of your release build.
来源:https://stackoverflow.com/questions/55536657/does-google-firebase-android-sdks-use-grpc