after enabling proguard,crash line number is incorrect - android

after enabling proguard,crash line number doesn show correctly
my hap has been published to google play and a user crash inside app,in my crash reporter,the crash line number is unknown and incorrect
java.lang.NullPointerException: null
at io.kuknos.messenger.fragments.NewWalletFragment$r$b.run(SourceFile:3)
at android.app.Activity.runOnUiThread(Activity.java:7154)
at io.kuknos.messenger.fragments.NewWalletFragment$r.a(SourceFile:5)
at z9.j$k0.a(SourceFile:10)
at z0.n.m(SourceFile:2)
at z0.e$b.run(SourceFile:5)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8653)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Add the following lines to your proguard configuration.
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
Now your stack traces will include line numbers, and by using the retrace tool that ships with proguard (included in the Android SDK), you are able to debug like normal.
Note that even if you didn't use these two configuration options, retrace still can output useful information provided you have the mappings file, albeit not totally unambiguously.
Note: the file with the mappings is produced by the proguard configuration option:
-printmapping outputfile.txt
In the ant file shipped with the Android SDK, it is set to mapping.txt.
Good luck.

Related

Proguard Overflow of unsigned short value

After adding a jar file containing some functionality that I need to my application, my proguard build hasn't been working. the error message I get after running my proguard build is:
Warning: Exception while processing task java.io.IOException: java.lang.RuntimeException: Unexpected error while writing class [proguard/optimize/gson/_OptimizedTypeAdapterFactory] (Overflow of unsigned short value [93362])
Thread(Tasks limiter_1): destruction
Is there any way to exclude that jar file from being checked by ProGuard? I'm using ProGuard v6.2.2. I suspected the issue would be GSON since i had issues with it before this error.
I've also checked and researched answers here such as Proguard [ java.lang.IllegalArgumentException: Overflow of unsigned short value ]
Android crash while using GSON Library and ProGuard
#732 Exception while handling very long string argument
Any help would be appreciated.
You can read more about ProGuard configuration and optimizations here:
https://www.guardsquare.com/en/products/proguard/manual/usage/optimizations
but in your case you can exclude the gson library that is throwing the exception like this:
-optimizations !library/gson
That's a known bug. Until this had been rectified, you can only disable the code optimization:
-optimizations !code/simplification/string
Or disable optimization altogether with -dontoptimize. Or just use R8 instead ...
That one linked answer which suggests a version-downgrade might also work.

Android Crashlytics sending incorrect line number

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*
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.
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!
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.
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.**
I had same issue, a simple observation solve my issue, see proguard-rule and uncomment these line
(-keepattributes SourceFile,LineNumberTable)
and
(-renamesourcefileattribute SourceFile)

Crashes and ANR on android developer, unknown classes

Today i've checked my crashes and ANR on my google play developer account, The thing is for every crash, The location of the error doesn't exist in my project. I'm getting something like:
nameofpackage.ui.activities.ak.a
My package called activities doesn't have any class called ak, neither a !
also:
nameofpackage.ui.chants.a.onClick
Chants also doesn't have a class called a !
is this normal?
Those names probably generated by proguard. if you have the line:
-printmapping out.map
Inside the rules file of proguard then you have file called:
out.map
In your project tree, there you can see what was the origin class of this Exception.
resolved, there is proguardgui which retrace the pile. You can fin it in:
sdk\tools\proguard\bin

Android log deobfuscation/retrace

I need some help with Android log file deobfuscation .
The problem is that if I have an exception like:
...
10-16 10:03:10.488: E/AndroidRuntime(25723): Caused by: java.lang.NullPointerException
10-16 10:03:10.488: E/AndroidRuntime(25723): at proguard.test.a.a(Unknown Source)
...
the retrace return original log but if I paste to log function name and line like:
...
10-16 10:03:10.480: I/ghghghg(25723): Crash in function [proguard.test.a.a() Line : -1 ]
...
the retrace doesn't deofescates that log line.
I know that there is an -regex parameter to retrace command but I can't find any explanation or sample. The Proguard retrace manual is unavailable on http://proguard.sourceforge.net/manual/retrace/usage.html.
How can I configure the retrace to deobfuscate custom lines in log?
The ProGuard manual (online, and also included in the ProGuard distribution) contains an example. It uses java.util.regex syntax with some additional wildcards for class names, etc.
You can try recat. It's a python script based on logcat-color, made exactly for this scenario, on-the-fly logcat deobfuscation (doesn't work on Windows though).

Obfuscated apk code crash log

I'am working with a large android project,very large,and we obfuscate our code when we release our apk to market,now the trouble is:
when our application crashed,actually,our application would post the crash log to our service,but the crash log make no mean,because we have obfuscated it already,we got infomation like this:a(),b(Unknown Source),c()....
so,how to deal with it?how to geting a readable crash log in obfuscate apk?Thanks!
When you obfuscate your code, a file called mapping.txt is generated. This file describes the mapping between your original symbols and their obfuscated versions.
If you save this file for your public builds, you can use the retrace tool to deobfuscate any stack traces you receive from crashes, thereby making them useable for fixing bugs! You invoke the tool as follows:
retrace.sh -verbose mapping.txt obfuscated_trace.txt

Categories

Resources