Proguard retrace.sh stack - android

I am struggling to understand debug information supplied by retrace.sh on my Android app. Why does it show 2 methods?
at java.lang.Thread.run(Thread.java:1027) Caused by: java.lang.NullPointerException
at com.mytaxicontrol.MyTaxiControlActivity$calctarif.java.lang.Void doInBackground$10299ca()(Unknown Source)
void nexttariflimit(boolean,boolean)
boolean newtaximoved(int,com.mytaxicontrol.MyTaxiControlActivity$nTW)
at com.mytaxicontrol.MyTaxiControlActivity$calctarif.java.lang.Object doInBackground(java.lang.Object[])(Unknown Source)

For lack of line numbers in the stack trace, ReTrace can't determine the original methods unambiguously, so it prints out all possible alternatives.
Cfr. ProGuard manual > ReTrace manual > Examples
Cfr. ProGuard manual > Examples > Producing useful obfuscated stack traces

Related

AndroidApp crashes when installed from the play store

I have an app that I have recently submitted to the play store. I had tested the .apk file and everything was working fine. On the first install (from the store) - you can login but then it crashes. Here is the stack trace I am getting from the report:
java.lang.NullPointerException
at com.latlon.InitialSearchActivity.e(Unknown Source)
at com.latlon.InitialSearchActivity.a(Unknown Source)
at com.latlon.InitialSearchActivity.g(Unknown Source)
at com.latlon.InitialSearchActivity.a(Unknown Source)
at com.latlon.MyResultReceiver.onReceiveResult(Unknown Source)
at android.os.ResultReceiver$MyRunnable.run(ResultReceiver.java:43)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:4385)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
I am just not real sure where to start looking. Any ideas?
Well, this part of the stack trace is your code:
java.lang.NullPointerException
at com.latlon.InitialSearchActivity.e(Unknown Source)
at com.latlon.InitialSearchActivity.a(Unknown Source)
at com.latlon.InitialSearchActivity.g(Unknown Source)
at com.latlon.InitialSearchActivity.a(Unknown Source)
at com.latlon.MyResultReceiver.onReceiveResult(Unknown Source)
Your onReceiveResult() method in class MyResultReceiver was called. That method called a method a in the InitialSearchActivity class, which called a method g in that class which called a method a in that class which called a method e in that class. In method e there was a NullPointerException (ie: in that method you tried to use a variable that you thought contained an object reference, but instead that variable contained null.
It looks like the method names have been obfuscated, so you may have to look at the code to figure out what the real method names are.
Looks like you used some toole (like Proguard) to obfuscate your code.
Did you test your APK after obfuscation?
From the logs above a NullPointerException has occured in your code, you'd need to de-obfuscate your code using the key files generated by the obfuscating tool in order to find out the real place (line of code) where null pointer has been accessed.
Please Note,
In the process of obfuscation, sometimes (human error) can cause some of the required methods to be obfuscated. Which in turn causes those methods not to be found, hence an exception (NoSuchMethod) might be raised.
Check the documentation on Proguard (which is the tool that does the code obfusciation).
It is very likely that you "over-obfusciated", which can cause issues with the deployed code. Just like you are seeing.
You can turn off Proguard functionality by editing the "proguard-project.txt" file. To ensure no obfusciation occurs, make sure every line in this file is commented out (by placing a hash - or # mark at the start of each line).
There is a command called retrace that allows you to provide unmap your obfusciation. You will need to provide some files created by proguard to get this working.
Check the docs for full explanation: http://developer.android.com/tools/help/proguard.html
Quick fix (to eliminate Proguard) is to comment the file, so it doesn't run in the first place.

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).

howto in eclipse debug the Proguard obfuscated apk file

I got a crash in my app after using Proguard and signing and exporting with a new key.
The same code works in normal eclipse debug mode.
I read everywhere i should use the mapping.txt to find the code that failed.
But how to do that, I have google this for 2 hour now and no answer is working.
Im now signing the apk file with the debug.keystore and using the default password "android".
Someone say i should android:debuggable="false" in my application tag to make
Proguard obfuscate my debug session in eclipse.
Is this right?
Any help would be grate
on the Proguard Android Developer page I cannot find a way to do this
"When your obfuscated code outputs a stack trace, the method names are obfuscated, which makes debugging ha"
What "stack trace" and from where?
On the page Proguard Manual I cannot find an explanation
You can de-obfuscate the stack trace most easily using the Proguard GUI. You'll find this with your Android SDK.
sdk\tools\proguard\bin\proguardgui.bat
Run the GUI above from the path above.
Click the 'ReTrace' button at the bottom of the panel on the left.
Add the path to your Mapping File (mapping.txt) in the 'Mapping file' text box.
Paste a copy of your stack trace in the 'Obfuscated stack trace' text box.
Click 'ReTrace' in the bottom right.
Happy Debugging!
Not within Eclipse.
Outside of Eclipse, use Retrace function within ProGuard. You'll also need the dumped stacktrace and mapping.txt found under your project's proguard directory to reverse the obfuscated stacktrace. Remember to save a copy of mapping.txt (preferably outside of your project's workspace) each time you deploy a new version of your Android app.
Been looking into this, the documentation for proguard on the android developer site demonstrates how to decode a stack trace, but it does not specify how to get the stack trace.
http://developer.android.com/guide/developing/tools/proguard.html (see section Decoding Obfuscated Stack Traces)
I tried to use a logcat dump as follows:-
E/AndroidRuntime(14584): FATAL EXCEPTION: main
E/AndroidRuntime(14584): java.lang.ExceptionInInitializerError
E/AndroidRuntime(14584): at com.a.a.b.a.dg.<init>(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.a.q.a(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.a.y.a(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.a.y.a(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.a.aq.get(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.cp.a(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.ai.c(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.bg.a(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.a.o.a(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.ee.a(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.ag.a(Unknown Source)
E/AndroidRuntime(14584): at com.a.a.b.cb.a(Unknown Source)
Unfortunately this does not work, but it does work if I remove the E/AndroidRuntime(14584) from the beginning of each line it does work:
FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.a.a.b.a.dg.<init>(Unknown Source)
at com.a.a.b.a.q.a(Unknown Source)
at com.a.a.b.a.y.a(Unknown Source)
at com.a.a.b.a.y.a(Unknown Source)
at com.a.a.b.a.aq.get(Unknown Source)
at com.a.a.b.cp.a(Unknown Source)
at com.a.a.b.ai.c(Unknown Source)
at com.a.a.b.bg.a(Unknown Source)
at com.a.a.a.o.a(Unknown Source)
at com.a.a.b.ee.a(Unknown Source)
at com.a.a.b.ag.a(Unknown Source)
at com.a.a.b.cb.a(Unknown Source)
So as the documentation states you need a stack trace file, and there appears to be no indication of getting a valid stack trace file from the device.
The only way I have seen this done is by providing a custom exception handler and writing the stack trace to the sdcard.
For mac user use bellow code to run the
/Users/XYZ/Library/Android/sdk/tools/proguard/bin/proguardgui.sh
Run the GUI above from the path above.
Click the 'ReTrace' button at the bottom of the panel on the left.
Add the path to your Mapping File (mapping.txt) in the 'Mapping
file' text box.
Paste a copy of your stack trace in the 'Obfuscated stack trace'
text box. Click
'ReTrace' in the bottom right.
Happy Debugging!
Steps to get obfuscated apk:
Download latest proguard from proguard site. Current latest version is proguard4.7
Replace "bin" and "lib" folder of C:\Program Files (x86)\Android\android-sdk\tools\proguard with latest downloaded proguard folders.
Check SDK location in eclipse for blank spaces in it and for that go to Window > Preferences > Android. If there is blank space then replace it with:
c:\Progra~2\android\android-sdk (for windows 64-bit)
c:\Progra~1\android\android-sdk (for windows 32-bit)
Check that proguard.cfg file is in your project's root folder and add proguard.config=proguard.cfg in project.properties file of android project.
Now export your project to get obfuscated apk.

Proguard retrace output confusion

I have here a stack trace from one of my games from android market. I have de-proguarded it but I can't really understand it!
I'm not asking for help in the error itself, but just how to interpret this.
I started with this from Market:
java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:299)
at com.a.a.k.o.a(Unknown Source)
at com.a.a.k.w.a(Unknown Source)
at com.a.a.k.w.onDrawFrame(Unknown Source)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
But retrace.bat has output this, which is longer, so I can't tell what com.a.a.k.o.a is (for exmaple).
java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:299)
at com.eaw.graphics.WorldViewShader.void glSetMVPMatrix(float[])(Unknown Source)
void glSetNormalMatrix(com.eaw.graphics.AMatrix)
void SetVertices(java.nio.FloatBuffer)
void ApplyArgs(com.eaw.graphics.WorldViewShaderArgs)
at com.eaw.graphics.TriangleRenderer.void onDrawFrame(com.eaw.airrace.ILayer,com.eaw.airrace.StepOutput,boolean)(Unknown Source)
void loadTexture$332cd44f(int[],int,int)
void delayedLoadTexture(int[],int[],int,int)
at com.eaw.graphics.TriangleRenderer.void onDrawFrame(javax.microedition.khronos.opengles.GL10)(Unknown Source)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
Has it rolled 4 functions into 1 during obscuration? or what?
You should add -keepattributes SourceFile,LineNumberTable to your proguard configuration file!
Your processed code and stack trace doesn't contain line numbers, so ProGuard can't tell to which original method name the obfuscated method name 'a' corresponds. It then prints out all possible alternatives. Cfr. ProGuard's Retrace manual.
The manual also documents how you can preserve line numbers in the obfuscation step.

Proguard retrace isnt mapping the stack trace to the actual source

I have been using the eclipse built in proguard tool to obsucate the code, which Works fine. However when I try to retrace the stack trace of the obfuscated code, retrace doesn't output an un-obfuscated stacktrace.
I have double check the mapping.txt to sure that i am using the right one.
here is my stack trace
ERROR/AndroidRuntime(19398):
FATAL EXCEPTION: Thread-35
ERROR/AndroidRuntime(19398): java.lang.NullPointerException
ERROR/AndroidRuntime(19398): at android.graphics.Canvas.throwIfRecycled(Canvas.java:954)
ERROR/AndroidRuntime(19398): at android.graphics.Canvas.drawBitmap(Canvas.java:980)
ERROR/AndroidRuntime(19398): at com.excelectronic.b.aa.a(ProGuard:535)
ERROR/AndroidRuntime(19398): at com.excelectronic.g.f.a(ProGuard:220)
ERROR/AndroidRuntime(19398): at com.excelectronic.game.GameView.a(ProGuard:198)
ERROR/AndroidRuntime(19398): at com.excelectronic.game.GameView.onDraw(ProGuard:98)
ERROR/AndroidRuntime(19398): at com.excelectronic.game.ac.run(ProGuard:121)
and using the command
retrace.bat -verbose mapping.txt obfuscated_trace.txt
ProGuard's ReTrace tool by default expects the stack traces to be nicely formatted, the way they are printed out by java. This means that it expects line breaks in the proper places and no prefixes like "ERROR/AndroidRuntime(19398)".
Alternatively, you can modify the regular expression that ReTrace uses for parsing the stack traces.
Use traceview to extract the original Java stack trace before using ReTrace.

Categories

Resources