Reputation: 371
I'm facing an issue when using OkHttp3 with minifyEnabled (R8) in my Android app. With R8 enabled, I encounter the following runtime error:
java.lang.IllegalStateException: Unexpected default trust managers: [android.security.net.config.RootTrustManager@9e26a00]
at okhttp3.internal.platform.Platform.platformTrustManager(Platform.kt:82)
at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:237)
at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:222)
at retrofit2.Retrofit$Builder.build(Retrofit.java:628)
Here’s a simplified version of my code:
OkHttpClient client = new OkHttpClient.Builder()
.build();
Retrofit retrofit = new Retrofit.Builder()
.client(client)
.build();
I included the official ProGuard rules for Retrofit and OkHttp, but they’re unnecessary since I’m using R8 for optimization.
Upvotes: 0
Views: 37
Reputation: 371
Well, I just needed to waste my time and write the question, so suddenly fix it, great.
Add these lines to proguard-rules.pro
:
-keep class javax.net.ssl.** { *; }
-keep class android.security.net.config.** { *; }
Upvotes: 0