Android Crashlytics sending incorrect line number
Asked Answered
O

5

16

I'm trying to integrate Crashlytics with my app and it's working, however the line number passed through seems to be incorrect. This is a stack I'm getting for my test exception:

Fatal Exception: java.lang.RuntimeException: This is a test crash
   at com.myapp.testapp.activity.MainActivity.animateReveal(MainActivity.java:42453)
   at com.myapp.testapp.activity.MainActivity.onClick(MainActivity.java:1356)
   at android.view.View.performClick(View.java:5204)
   at android.view.View$PerformClick.run(View.java:21153)
   at android.os.Handler.handleCallback(Handler.java:739)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:148)
   at android.app.ActivityThread.main(ActivityThread.java:5417)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

So my crash is on line number 1453 but for some reason it's showing up as 42453? Interestingly, the next line number in the stack is correct...

Proguard:

# Crashlitics

-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keepattributes *Annotation*
Orthopteran answered 22/7, 2016 at 14:43 Comment(0)
P
3

To preserve the information that Firebase Crashlytics SDK requires for producing readable crash reports, add the following lines to your Proguard or Dexguard config file:

-keepattributes SourceFile,LineNumberTable        # Keep file names and line numbers.
-keep public class * extends java.lang.Exception  # Optional: Keep custom exceptions.
Populace answered 14/7, 2020 at 16:55 Comment(0)
S
1

Likely it's because you're using a release build which will remove comments/ white spaces.

If you're using a debug build then it may show the correct lines, because it won't optimize your source code...

Still I'm guessing there is another reason for the line numbers to show incorrect, because Fabric was telling me the crash was happening at line 400, even though that function was called at line 300. I mean if comments and white spaces are to be removed, Fabric should have told line some line less than 300, not more!

Serrate answered 2/10, 2017 at 15:1 Comment(0)
D
1

In my case switching from 'proguard-android-optimize.txt' default proguard file to 'proguard-android.txt' fixed the issue. Using the optimized version of the proguard file can introduce certain risks and it seems that this is one of them.

Davisdavison answered 23/5, 2018 at 13:56 Comment(1)
I should try this!Carrero
J
1

I had same issue, a simple observation solve my issue, see proguard-rule and uncomment these line (-keepattributes SourceFile,LineNumberTable)

and

(-renamesourcefileattribute SourceFile)

Jailhouse answered 30/4, 2021 at 6:21 Comment(0)
U
0

Did you try this?

For Fabric to properly de-obfuscate your crash reports, you need to remove this line from your configuration file, or we won’t be able to automatically upload your mapping file:

-printmapping mapping.txt

and

-keep class com.crashlytics.** { *; }

-dontwarn com.crashlytics.**

Usury answered 27/9, 2016 at 4:51 Comment(3)
my setup conforms to that and the issue is still presentDonnettedonni
post full proguard fileUsury
I'm afraid I can't but it's a standard one around Fabric (following their docs). The only thing is that it's based on Android SDKs one with optimisations and I'm not sure if the issue didn't start to appear since we switched to SDK's optimised one as default for our config.Donnettedonni

© 2022 - 2024 — McMap. All rights reserved.