12

Getting these warning while using r8

Missing class org.bouncycastle.jsse.BCSSLParameters (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 1 other context)
Missing class org.bouncycastle.jsse.BCSSLSocket (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 5 other contexts)
Missing class org.bouncycastle.jsse.provider.BouncyCastleJsseProvider (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.<init>())
Missing class org.conscrypt.Conscrypt$Version (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int))
Missing class org.conscrypt.Conscrypt (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int) and 4 other contexts)
Missing class org.conscrypt.ConscryptHostnameVerifier (referenced from: okhttp3.internal.platform.ConscryptPlatform$DisabledHostnameVerifier)
Missing class org.openjsse.javax.net.ssl.SSLParameters (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List))
Missing class org.openjsse.javax.net.ssl.SSLSocket (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 1 other context)
Missing class org.openjsse.net.ssl.OpenJSSE (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.<init>())

Tried using this but it did not work.

-keep class com.squareup.okhttp.** { *; }
Uzzam Altaf
  • 303
  • 4
  • 8

3 Answers3

12

Actually this seems to be now fixed in OkHttp version 4.11.0, released on April 2023: https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp-bom

I had the same issue and once I updated to this version, the build goes through successfully

Piidro
  • 716
  • 8
  • 18
9

Fixed in okhttp 5 https://github.com/square/okhttp/issues/6258

Add rulse from https://raw.githubusercontent.com/square/okhttp/master/okhttp/src/jvmMain/resources/META-INF/proguard/okhttp3.pro

-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**
k4dima
  • 6,070
  • 5
  • 41
  • 39
0

Missing classes when compiling with R8 means that there are references to these classes in the input, but they have no definition in the input neither in the program itself, on the classpath or in the library/bootclasspath (android.jar when building Android apps). The -keep rule is used to keep classes already present in the input, and has no effect on missing classes (it might actually end up giving more missing classes).

To silence the warnings about missing classes the -dontwarn directive can be used, e.g.:

-dontwarn org.bouncycastle.jsse.BCSSLParameters

Before going ahead with adding -dontwarn make sure that the missing classes are not due to a missing dependency, which might end up causing runtime failures.

sgjesse
  • 3,793
  • 14
  • 17