Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
src/ | 03-May-2024 | - | 2,357 | 1,756 | ||
.gitignore | D | 03-May-2024 | 6 | 2 | 1 | |
README.md | D | 03-May-2024 | 1.7 KiB | 46 | 34 | |
build.gradle | D | 03-May-2024 | 1.3 KiB | 51 | 43 | |
proguard-rules.pro | D | 03-May-2024 | 465 | 14 | 11 |
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