Closed forgetW closed 2 years ago
First copy Java Files to your project
//Cronet embedded version
implementation 'org.chromium.net:cronet-embedded:101.4951.41'
//or use play services version
implementation 'com.google.android.gms:play-services-cronet:18.0.1'
// guava
implementation 'com.google.guava:guava:31.1-android'
// annotation
implementation 'androidx.annotation:annotation:1.3.0'
//okhttp 3.x or 4.x or 5.x
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
Create CronetEngine
CronetEngine engine = new CronetEngine.Builder(applicationContext).build();
Create OkhttpClient
OkHttpClient okhttpclient=new OkHttpClient.Builder()
.....
.addInterceptor(CronetInterceptor.newBuilder(engine).build()) //must be latest application Interceptor
.build();
I have implementation 'org.chromium.net:cronet-embedded:101.4951.41'
in my application, but I don't have the CronetInterceptor
class, only the cronet specific classes.
Hi,
We don't publish pre-compiled binaries yet (coming soon, stay tuned).
For now, you either need to copy the code over to your application project; or build the library separately and add it as a compiled dependency.
The library works with OkHttp 3+ and doesn't include OkHttp classes (and their dependencies) in the jar. Instead, it depends on your application's classpath so you can keep using the OkHttp version you like.
Any progress for a precompiled maven dependency? I want to avoid adding a gitmodule / copying this directly to my application code.
We are also waiting for the pre-compiled binaries to be published, thanks in advance.
Apologies for the wait everyone, I'm on parental leave. Expect an update the week after next.
Sorry for the delay everyone, I ended up taking a couple more weeks. I'll aim to at least add a binary release on GitHub this week.
Would that be usable by maven/gradle directly? That's what I'm looking for currently in my use case.
I created a preliminary release on https://github.com/google/cronet-transport-for-okhttp/releases/tag/release-ed5851e and added instructions on how to use it. I'll aim to add a proper Maven artifact ASAP.
This artifact, including dependencies, is now also available as com.google.net.cronet:cronet-okhttp:0.1.0
natively from Maven.
Any plan to publish another update to maven? as we need commit 0a43782448 fix, thank you! 🙏
Happy New Year everyone, it'll be a bit of a busy week for me but I'll see what we can do to have another one-off Maven release.
How to use it in Android? What are the versions of okhttp and other dependencies?