我已经使用 android studio 一段时间了,每当发生异常时,堆栈跟踪中显示的信息不包含发生错误的类或行号。它甚至没有像它应该的那样染成蓝色。下面是抛出的堆栈跟踪示例:
ava.lang.StringIndexOutOfBoundsException: length=2; index=3
at java.lang.String.indexAndLength(String.java:579)
at java.lang.String.substring(String.java:1438)
at com.patriceandala.myapplication.utils.D.a(SourceFile:101)
at com.patriceandala.myapplication.utils.D.a(SourceFile:29)
at com.patriceandala.myapplication.utils.B.a(SourceFile:77)
at d.b.a.a.run(SourceFile:46)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5371)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
它只显示“SourceFile”,但我没有该名称的类。我该如何解决这个问题?
最佳答案
在 Debug模式下禁用 ProGuard
并检查。
Proguard 是一个免费的 Java 类文件收缩器、优化器、混淆器和预 validator 。它使代码不可读。所以在 Debug模式下禁用它。
关于java - Android Studio 不显示异常类和行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58321037/