• Home
Name Date Size #Lines LOC

..--

src/03-May-2024-2,3561,755

.gitignoreD03-May-20246 21

README.mdD03-May-20241.7 KiB4634

build.gradleD03-May-20241.3 KiB5143

proguard-rules.proD03-May-2024465 1411

README.md

1gRPC Cronet Transport
2========================
3
4**EXPERIMENTAL:**  *gRPC's Cronet transport is an experimental API, and is not
5yet integrated with our build system. Using Cronet with gRPC requires manually
6integrating the gRPC code in this directory into your Android application.*
7
8This code enables using the [Chromium networking stack
9(Cronet)](https://chromium.googlesource.com/chromium/src/+/master/components/cronet)
10as the transport layer for gRPC on Android. This lets your Android app make
11RPCs using the same networking stack as used in the Chrome browser.
12
13Some advantages of using Cronet with gRPC:
14* Bundles an OpenSSL implementation, enabling TLS connections even on older
15  versions of Android without additional configuration
16* Robust to Android network connectivity changes
17* Support for [QUIC](https://www.chromium.org/quic)
18
19Cronet jars are available on Google's Maven repository. See the example app at
20https://github.com/GoogleChrome/cronet-sample/blob/master/README.md. To use
21Cronet with gRPC, you will need to copy the gRPC source files contained in this
22directory into your application's code, as we do not currently provide a
23`grpc-cronet` dependency.
24
25To use Cronet, you must have the `ACCESS_NETWORK_STATE` permission set in
26`AndroidManifest.xml`:
27
28```
29<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
30```
31
32Once the above steps are completed, you can create a gRPC Cronet channel as
33follows:
34
35```
36import io.grpc.cronet.CronetChannelBuilder;
37import org.chromium.net.ExperimentalCronetEngine;
38
39...
40
41ExperimentalCronetEngine engine =
42    new ExperimentalCronetEngine.Builder(context /* Android Context */).build();
43ManagedChannel channel = CronetChannelBuilder.forAddress("localhost", 8080, engine).build();
44```
45
46