Proguard R8 警告

Uzz*_*taf 12 android proguard kotlin android-r8

使用 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>())

Run Code Online (Sandbox Code Playgroud)

尝试使用这个但没有成功。

-keep class com.squareup.okhttp.** { *; }
Run Code Online (Sandbox Code Playgroud)

Pii*_*dro 15

实际上,这个问题现在似乎已4.11.0在 2023 年 4 月发布的 OkHttp 版本中修复:https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp-bom

我遇到了同样的问题,一旦更新到此版本,构建就会成功完成


sgj*_*sse 1

使用 R8 编译时缺少类意味着输入中存在对这些类的引用,但它们在输入中没有定义,无论是在程序本身、类路径上还是在库/bootclasspath 中(android.jar构建 Android 应用程序时)。该-keep规则用于保留输入中已存在的类,并且对丢失的类没有影响(实际上可能最终会给出更多丢失的类)。

为了消除有关缺少类的警告,-dontwarn可以使用指令,例如:

-dontwarn org.bouncycastle.jsse.BCSSLParameters
Run Code Online (Sandbox Code Playgroud)

在继续添加之前,-dontwarn请确保缺少的类不是由于缺少依赖项而导致的,这可能最终导致运行时失败。