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
相关产品推荐
相关产品推荐

