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

Debug版文字识别正常,Release版出现FirebaseML内部错误如何解决?

Firebase ML文字识别Release版本运行异常修复

文字识别功能在Debug构建版本中可正常运行,但打包Release版本后触发如下错误:

com.google.firebase.ml.common.FirebaseMLException: Internal error has occurred when executing Firebase ML tasks
                                                                                                        at ok.a8.run(SourceFile:20)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                        at android.os.Looper.loop(Looper.java:313)
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67)
                                                                                                    Caused by: java.lang.IllegalArgumentException: 
                                                                                                        at ok.a2.c(SourceFile:1079)
                                                                                                        at ok.a2.b(SourceFile:19)
                                                                                                        at com.google.android.gms.internal.firebase_ml.b.f(SourceFile:1853)
                                                                                                        at ok.u8.e(SourceFile:123)
                                                                                                        at ok.v8.d(SourceFile:5)
                                                                                                        at gl.g2.call(SourceFile:134)
                                                                                                        at ok.a8.run(SourceFile:5)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:942) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226) 
                                                                                                        at android.os.Looper.loop(Looper.java:313) 
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67) 
                                                                                                    Caused by: java.lang.IllegalArgumentException: unable to create new instance of class ok.o3 because it is abstract and because it has no accessible default constructor
                                                                                                        at ok.b.g(SourceFile:173)
                                                                                                        at ok.b.F(SourceFile:7)
                                                                                                        at ok.l2.i(SourceFile:26)
                                                                                                        at ok.a2.c(SourceFile:669)
                                                                                                        at ok.a2.b(SourceFile:19) 
                                                                                                        at com.google.android.gms.internal.firebase_ml.b.f(SourceFile:1853) 
                                                                                                        at ok.u8.e(SourceFile:123) 
                                                                                                        at ok.v8.d(SourceFile:5) 
                                                                                                        at gl.g2.call(SourceFile:134) 
                                                                                                        at ok.a8.run(SourceFile:5) 
                                                                                                        at android.os.Handler.handleCallback(Handler.java:942) 
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226) 
                                                                                                        at android.os.Looper.loop(Looper.java:313) 
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67) 
                                                                                                    Caused by: java.lang.InstantiationException: java.lang.Class<ok.o3> cannot be instantiated
                                                                                                        at java.lang.Class.newInstance(Native Method)

问题原因

ProGuard混淆过程中误处理了Firebase ML的内部核心类,导致反射实例化类时失败,触发无法实例化抽象类/无默认构造方法类的异常。

修复方案

在ProGuard配置文件(通常为proguard-rules.pro)中添加以下规则,保留Firebase ML的内部包类不被混淆:

-keep class com.google.android.gms.internal.firebase_ml.** { *; }

添加完成后重新打包Release版本,文字识别功能即可恢复正常运行。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 19:13:18