You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

开启minifyEnabled=true后APP调用API无响应问题如何解决

解决Missing class: org.conscrypt.ConscryptHostnameVerifier报错

该问题由开启混淆后R8/ProGuard误移除网络库依赖的Conscrypt安全库类导致,直接在项目proguard-rules.pro文件中添加如下混淆规则即可:

# 保留Conscrypt相关类
-keep class org.conscrypt.ConscryptHostnameVerifier { *; }
-keep class org.conscrypt.** { *; }
-dontwarn org.conscrypt.**

如果项目使用OkHttp作为网络请求框架,可以补充官方推荐的混淆规则,避免其他网络类被误处理:

# OkHttp3官方混淆规则
-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**

解决Parameter specified as non-null is null: method j.u.b.g.e, parameter message崩溃

你看到的j.u.b.g.e是混淆后的类简写,首先添加如下混淆规则保留调试属性,方便后续问题定位:

-keepattributes SourceFile,LineNumberTable
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses

崩溃的核心原因是异常实例的message字段为空,但接收该参数的方法将其声明为了Kotlin非空类型,按如下步骤修复:

  • 检查项目中所有调用Throwable.message的代码位置,增加空校验,或改为可空类型接收参数
  • 补充Kotlin相关混淆规则,避免标准库类被误优化:
-keep class kotlin.** { *; }
-dontwarn kotlin.**
-keepclassmembers class **$WhenMappings {
    public <fields>;
}

补充:Google Play去混淆文件上传说明

开启minifyEnabled = true后,构建Release版本时会自动在build/outputs/mapping/对应渠道/对应构建类型/目录下生成mapping.txt映射文件,上传App Bundle到Google Play后台时,同步上传该文件即可消除最初的无去混淆文件警告。


内容的提问来源于stack exchange,提问作者Mohamed Mohamed Taha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 10:33:04