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

Android Studio构建OkHttp发布版App触发NullPointerException求助

问题:Release版本运行触发NullPointerException,Debug版本正常

运行App的Release版本时出现如下致命异常,Debug版本可正常运行:

FATAL EXCEPTION: e9.s Dispatcher
Process: com.example.premi, PID: 18240
java.lang.NullPointerException: getConnectionId(...) must not be null
at y4.c.a(SourceFile:392)
at y4.i$b.d(SourceFile:87)
at i9.e$a.run(SourceFile:43)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

触发该致命异常前,OkHttp客户端会返回错误码400的Callback失败。

曾尝试添加以下ProGuard规则,但未解决问题:

# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**

# A resource is loaded with a relative path so the package of this class must be preserved.
-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz

# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

# OkHttp platform used only on JVM and when Conscrypt and other security providers are available.
-dontwarn okhttp3.internal.platform.**
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**

编辑: 通过mapping.txt追踪错误,定位到问题出在SignalR,已在proguard-rules.pro中添加以下规则:

-keep class com.microsoft.signalr.** { *; }
-keep interface com.microsoft.signalr.** { *; }

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 22:12:11