Name Date Size #Lines LOC

..--

src/H25-Apr-2025-2,6812,003

.gitignoreH A D25-Apr-20256 21

README.mdH A D25-Apr-20252 KiB5538

build.gradleH A D25-Apr-20252.3 KiB9785

proguard-rules.proH A D25-Apr-2025465 1411

README.md

1gRPC Cronet Transport
2========================
3
4**EXPERIMENTAL:**  *gRPC's Cronet transport is an experimental API. Its stability
5depends on upstream Cronet's implementation, which involves some experimental features.*
6
7This code enables using the [Chromium networking stack
8(Cronet)](https://chromium.googlesource.com/chromium/src/+/master/components/cronet)
9as the transport layer for gRPC on Android. This lets your Android app make
10RPCs using the same networking stack as used in the Chrome browser.
11
12Some advantages of using Cronet with gRPC:
13
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
19Since gRPC's 1.24 release, the `grpc-cronet` package provides access to the
20`CronetChannelBuilder` class. Cronet jars are available on Google's Maven repository.
21See the example app at https://github.com/GoogleChrome/cronet-sample/blob/master/README.md.
22
23## Example usage:
24
25In your app module's `build.gradle` file, include a dependency on both
26`io.grpc:grpc-cronet` and the Google Play Services Client Library for Cronet,
27`com.google.android.gms:play-services-cronet`.
28
29In cases where Cronet cannot be loaded from Google Play services, there is a less performant
30implementation of Cronet's API that can be used. Depend on `org.chromium.net:cronet-fallback`
31to use this fall-back implementation.
32
33
34You will also need permission to access the device's network state in your
35`AndroidManifest.xml`:
36
37```
38<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
39```
40
41Once the above steps are completed, you can create a gRPC Cronet channel as
42follows:
43
44```
45import io.grpc.cronet.CronetChannelBuilder;
46import org.chromium.net.ExperimentalCronetEngine;
47
48...
49
50ExperimentalCronetEngine engine =
51    new ExperimentalCronetEngine.Builder(context /* Android Context */).build();
52ManagedChannel channel = CronetChannelBuilder.forAddress("localhost", 8080, engine).build();
53```
54
55