okhttp-3.10.0 build错误:Type `org.conscrypt.Conscrypt` was not found, it is required for default

错误信息:
Type `org.conscrypt.Conscrypt` was not found, it is required for default or static interface methods desugaring of `okhttp3.internal.platform.Platform okhttp3.internal.platform.ConscryptPlatform.buildIfSupported()`
Message{kind=WARNING, text=Type `org.conscrypt.Conscrypt` was not found, it is required for default or static interface methods desugaring of `okhttp3.internal.platform.Platform okhttp3.internal.platform.ConscryptPlatform.buildIfSupported()`, sources=[/Users/xxx/build/intermediates/transforms/proguard/xx/debug/0.jar], tool name=Optional.of(D8)}

这里写图片描述
看到这个错误后, 就找到源码类查看,注意类最前面的一句注释:

import java.security.NoSuchAlgorithmException;
import java.security.Provider;
import java.util.List;
import javax.annotation.Nullable;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;
import okhttp3.Protocol;
import org.conscrypt.Conscrypt;
import org.conscrypt.OpenSSLProvider;

/**
 * Platform using Conscrypt (conscrypt.org) if installed as the first Security Provider.
 *
 * Requires org.conscrypt:conscrypt-openjdk-uber on the classpath.
 */

后面接着找到了插件库的下载地址org.conscrypt:conscrypt-openjdk-uber
这里写图片描述
所以咱们只要导入库即可
implementation 'org.conscrypt:conscrypt-openjdk-uber:1.1.3'

proguard-rules.pro 混淆配置

#org.conscrypt
-dontwarn org.conscrypt.**
-keep class org.conscrypt.** { *; }
-keep interface org.conscrypt.** { *; }
追加一句 后面 build发现 org.conscrypt包中的Platform类引用了sun包 import sun.security.x509.AlgorithmId;
   /**
     * OID to Algorithm Name mapping.
     */
    @SuppressWarnings("unused")
    static String oidToAlgorithmName(String oid) {
        try {
            return AlgorithmId.get(oid).getName();
        } catch (NoSuchAlgorithmException e) {
            return oid;
        }
    }
Type sun.security.x509.AlgorithmId was not found, it is required for default or static interface methods desugaring of java.lang.String org.conscrypt.Platform.oidToAlgorithmName(java.lang.String)
所以这个错误可忽略,不影响 build 运行与打包
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值