【问题标题】:Proguard R8 warningsProguard R8 警告
【发布时间】:2023-01-01 03:25:12
【问题描述】:

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

尝试使用它,但没有用。

-keep class com.squareup.okhttp.** { *; }

【问题讨论】:

    标签: android kotlin proguard android-r8


    【解决方案1】:

    已在 okhttp 5 中修复 https://github.com/square/okhttp/issues/6258

    添加规则来自 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.**
    

    【讨论】:

      【解决方案2】:

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

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

      -dontwarn org.bouncycastle.jsse.BCSSLParameters
      

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

      【讨论】:

        猜你喜欢
        • 2020-05-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-11-16
        • 2015-06-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多