gRPC server for Android

Viewed 1151

I'm new to Android. I need to build a gRPC server on the Android platform. I saw that people tried doing that, but did not succeed. It was stated that Netty was not supported on Android. Is there a way to build gRPC/proto (maybe using Dagger) server? Any help/examples will be much appreciated.

1 Answers

There is no HTTP/2 gRPC server available for Android. While the Netty server does run on Android, it is poorly optimized (size, memory, cpu) for Android and is not officially supported by the gRPC team because it doesn't represent their expectations for a server running on Android. I also expect that TLS may not be functional on some Android versions (due to ALPN APIs).

That said, if you need a HTTP/2 gRPC server on Android and don't care about TLS and performance (e.g., for use in tests), then I'd expect grpc-netty to mostly "just work." You may experience an error during compilation about duplicate files in META-INF/services, but that can be resolved with packagingOptions (ideally "merge", but "pickFirst" probably functions).

Note that C++ servers are supported on Android. There's even an example. This is also a different discussion than in-process servers (which is supported) and the in-progress Binder-based transport.

Related