I am using ProGuard in my application and problem is when users report some problem to my console and I can't decode it precisely because of "Unknown source".
Here is example of stacktrace:
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at com.my.package.j.a(Unknown Source)
at com.a.a.c.c.j(Unknown Source)
at com.a.a.c.c.b(Unknown Source)
at com.a.a.c.e.run(Unknown Source)
at java.lang.Thread.run(Thread.java:856)
Then I am using this code to decode it:
./retrace.sh -verbose mapping.txt stacktrace.txt > out.txt
And here is output:
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at com.my.package.MyFragment$10.void output(int,java.lang.String)(Unknown Source)
at com.stericson.RootTools.execution.Shell.void readOutput()(Unknown Source)
at com.stericson.RootTools.execution.Shell.void closeCustomShell()(Unknown Source)
com.stericson.RootTools.execution.Shell startShell(int)
void access$200(com.stericson.RootTools.execution.Shell)
at com.stericson.RootTools.execution.Shell$2.void run()(Unknown Source)
at java.lang.Thread.run(Thread.java:856)
It only shows name of Fragment when error occurred, but I also need exact line and method.
Your question has actually two parts.
1) Why are you missing the line information?
You are removing the line information during obfuscation. You need the following rules in your proguard.cfg
-renamesourcefileattribute MyApplication
-keepattributes SourceFile,LineNumberTable
Find details for retracing line numbers here: http://proguard.sourceforge.net/manual/retrace/examples.html#with
2) Why is it missing some method/class name, in your example
com.my.package.MyFragment$10.void
This is because $10 is most likely an anonymous class declaration which will be treated differently during compiling and subsequent obfuscation. First easy solution is of course to get rid of the anonymous declaration and declare it somewhere. Another solution would be to add the following line again to your proguard.cfg
-keepattributes EnclosingMethod
This of course will again not remove some information and will reduce your obfuscation.
Related
I am getting a Crash which is reported in Crashlytics for com.appsflyer.MultipleInstallBroadcastReceiver.onReceive in MultipleInstallBroadcastReceiver.java class
This Crash is been reported for few users in all the android verisons
Fatal Exception: java.lang.NoSuchMethodError: No virtual method 藡(Landroid/content/Context;Landroid/content/Intent;)V in class Lcom/appsflyer/AppsFlyerLib; or its super classes (declaration of 'com.appsflyer.AppsFlyerLib' appears in /data/app/com.rapido.passenger-1/base.apk)
at com.appsflyer.MultipleInstallBroadcastReceiver.onReceive(MultipleInstallBroadcastReceiver.java:43)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3112)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1627)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:165)
at android.app.ActivityThread.main(ActivityThread.java:6375)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
From the stack trace it seems to be an obfuscation issue (looking at the method name 藡)
What is the SDK version being used? Are there any proGuard (or other tool) rules configured for AppsFlyer?
If not I would suggest adding a -keep class com.appsflyer.** { *; } rule.
If you do not wish to share any additional information publicly, you can open a ticket with support#appsflyer.com, with the SDK version, any obfuscation related information and a link to this thread.
this is My Error info:
Unexpected error while performing partial evaluation:
Class = [org/apache/log4j/chainsaw/Main]
Method = [<init>()V]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [java/lang/NoClassDefFoundError] (with 5 known super classes) and [org/apache/log4j/chainsaw/LoadXMLAction] (with 1 known super classes))
Exception while processing task
java.lang.IllegalArgumentException: Can't find common super class of [java/lang/NoClassDefFoundError] (with 5 known super classes) and [org/apache/log4j/chainsaw/LoadXMLAction] (with 1 known super classes)
at proguard.evaluation.value.TypedReferenceValue.findCommonClass(TypedReferenceValue.java:441)
at proguard.evaluation.value.TypedReferenceValue.generalize(TypedReferenceValue.java:277)
at proguard.evaluation.value.TypedReferenceValue.generalize(TypedReferenceValue.java:201)
at proguard.evaluation.value.ReferenceValue.generalize(ReferenceValue.java:298)
at proguard.evaluation.Variables.generalize(Variables.java:136)
at proguard.evaluation.TracedVariables.generalize(TracedVariables.java:118)
at proguard.optimize.evaluation.PartialEvaluator.evaluateSingleInstructionBlock(PartialEvaluator.java:690)
at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlock(PartialEvaluator.java:594)
at proguard.optimize.evaluation.PartialEvaluator.visitExceptionInfo(PartialEvaluator.java:1079)
at proguard.classfile.visitor.ExceptionHandlerFilter.visitExceptionInfo(ExceptionHandlerFilter.java:67)
at proguard.classfile.attribute.CodeAttribute.exceptionsAccept(CodeAttribute.java:186)
at proguard.optimize.evaluation.PartialEvaluator.evaluateExceptionHandlers(PartialEvaluator.java:1019)
at proguard.optimize.evaluation.PartialEvaluator.evaluateInstructionBlockAndExceptionHandlers(PartialEvaluator.java:574)
at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute0(PartialEvaluator.java:271)
at proguard.optimize.evaluation.PartialEvaluator.visitCodeAttribute(PartialEvaluator.java:188)
at proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:101)
at proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:81)
at proguard.classfile.attribute.visitor.AllAttributeVisitor.visitProgramMember(AllAttributeVisitor.java:95)
at proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:92)
at proguard.classfile.ProgramMethod.accept(ProgramMethod.java:73)
at proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:516)
at proguard.classfile.visitor.AllMethodVisitor.visitProgramClass(AllMethodVisitor.java:47)
at proguard.classfile.visitor.ClassAccessFilter.visitProgramClass(ClassAccessFilter.java:67)
at proguard.classfile.ProgramClass.accept(ProgramClass.java:358)
at proguard.classfile.ClassPool.classesAccept(ClassPool.java:124)
at proguard.optimize.Optimizer.execute(Optimizer.java:462)
at proguard.ProGuard.optimize(ProGuard.java:328)
at proguard.ProGuard.execute(ProGuard.java:127)
at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139)
at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115)
at com.android.builder.tasks.Job.runTask(Job.java:48)
at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227)
at java.lang.Thread.run(Thread.java:745)
:mainAPlication:shrinkReleaseMultiDexComponents FAILED
if I set
minifyEnabled true
this error comes,
if I set
minifyEnabled flase
my proguardtask works fine,
this is my proguard.cfg File:
-optimizationpasses 1
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-dontshrink
-verbose
-microedition
-ignorewarnings
-keepattributes InnerClasses,Signature
-keepattributes *Annotation*
So ,I don't know how this error happen, this looks because minifyEnabled work error ,
does any body meet the same question.
when I add this line in proguard.cfg ,My build works
-dontoptimize
But I don't know which reason cause the error
It was likely an external library
I dug this up
http://sohu.io/questions/1918042/proguard-cant-find-any-super-classes
and sure enough along these lines I have a similar scenario:
Proguard fails to build due to compiling a library that contains Log4J. Get The owner of that library to remove log4j and invocations to it is the approach I am going to take. In particular for producation as proguard really should be used in a production/release scenario...
I have a problem with proguard config in Android Project.
I'm using Genson to parse incoming JSON data.
It is fast and there is no need for extra configuration or deserializers, because on the Server-side there is also Genson.
Everything works fine in debug mode, but in release, with proguard it doesn't.
Unfortunately I have some error during runtime:
FATAL EXCEPTION: main
Process: com.es.mobile.meedy, PID: 16650
java.lang.UnsupportedOperationException: Couldn't find parameter at 0 from type interface com.owlike.genson.Converter , you should first locate the parameterized type, expand it and then use typeOf.
at com.owlike.genson.reflect.TypeUtil.typeOf(Unknown Source)
at com.owlike.genson.GensonBuilder.withConverters(Unknown Source)
at com.mypackage.f.k.a(Unknown Source)
at com.a.a.b.n.a(Unknown Source)
at com.a.a.i.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
It happens even if datamodel is in keep class. I tried all configrations with keep class, classmembers, etc. What else can i do?
EDIT
What else do I know:
I tried keep class with all classes in my project.
I have keep class with genson (-keep class com.owlike.genson.** { *; })
Instanceof with my class shows that it is instance of com.owlike.genson.Converter
The solution to the problem was to add -keepattributes Signature
If annotations are being used then this option should be enabled too -keepattributes *Annotation*
Also the application class being ser/de by Genson must also be provided:
-keep class com.mypackage.model.** { *; }
-keep class com.owlike.genson.*{ *; }
Add that line to your ProGuard configuration.
-keep [,modifier,...] class_specification
Specifies classes and class members (fields and methods) to be preserved as entry points to your
code. For example, in order to keep an application, you can specify
the main class along with its main method. In order to process a
library, you should specify all publicly accessible elements.
I'm running ProGuard for my release build and trying to optimize it as much as possible. The only custom rules I've added so far are Serialization and Facebook ones. I'm running my release build now and I'm getting a stack trace and what it maps back to is really throwing me off. Here's my stack trace:
java.lang.NullPointerException
E/AndroidRuntime(10842): at com.myapp.android.myapp.dh.a(Unknown Source)
E/AndroidRuntime(10842): at android.support.v4.app.Fragment.b(Unknown Source)
E/AndroidRuntime(10842): at android.support.v4.app.w.a(Unknown Source)
E/AndroidRuntime(10842): at android.support.v4.app.p.onCreatePanelMenu(Unknown Source)
E/AndroidRuntime(10842): at android.support.v7.a.g.a(Unknown Source)
E/AndroidRuntime(10842): at android.support.v7.a.m.a(Unknown Source)
E/AndroidRuntime(10842): at android.support.v7.a.g.onCreatePanelMenu(Unknown Source)
In mapping, com.myapp.android.myapp.dh.a is:
com.myapp.android.myapp.LocalFragment -> com.myapp.android.myapp.dh:
java.lang.String USER_ACCOUNT -> a
In my actual code it's this:
public static String USER_ACCOUNT = "com.myapp.android.myapp.LocalFragment.user_account";
Now this constant is used in multiple places throughout this Fragment, but it should never be null. Anyone seen a problem like this before? Does Proguard do weird stuff with statics?
Edit: This error is thrown and the app crashes basically as soon as I take the action that would load this Fragment.
EDIT AGAIN
After a bit more investigation, I was wrong about what a was. a was that Static member, but a is also a method. It's the onCreate method. I'm also seeing this error in logcat before the NPE is thrown in onCreate:
W/SupportMenuInflater(10842): Cannot instantiate class: android.support.v7.widget.SearchView
W/SupportMenuInflater(10842): java.lang.NoSuchMethodException: <init> [class android.content.Context]
W/SupportMenuInflater(10842): at java.lang.Class.getConstructorOrMethod(Class.java:472)
W/SupportMenuInflater(10842): at java.lang.Class.getConstructor(Class.java:446)
W/SupportMenuInflater(10842): at android.support.v7.internal.view.e.a(Unknown Source)
W/SupportMenuInflater(10842): at android.support.v7.internal.view.e.a(Unknown Source)
W/SupportMenuInflater(10842): at android.support.v7.internal.view.c.a(Unknown Source)
W/SupportMenuInflater(10842): at android.support.v7.internal.view.c.inflate(Unknown Source)
W/SupportMenuInflater(10842): at com.myapp.android.myapp.dh.a(Unknown Source)
You have a problem with proguard obfuscating the support libraries, or specifically, the SearchView component that you probably try to initiate in your fragment. To avoid this, you need to add few exclusions to proguard configuration file (proguard.cfg).
-keep class android.support.v7.widget.** { *; }
-keep interface android.support.v7.widget.** { *; }
This will keep all classes and interfaces inside the widget package of the support library from being obfuscated.
I'm trying to deobfucate a stack trace from my Android app. I used proguard when building the app and running retrace seem to work, more or less.
What isn't working is decoding the line numbers. No line numbers are shown on the output and it lists several choices for each "at".
Here is my proguard-project.txt file:
-keepattributes LineNumberTable
-assumenosideeffects class android.util.Log {
public static int v(...);
public static int d(...);
}
This is my stack trace:
uncaught exception
java.lang.NullPointerException
at com.myapp.myapp.dbaccess.ag.a(Unknown Source)
at com.myuapp.myapp.dbaccess.x.a(Unknown Source)
at com.myapp.myapp.dbaccess.x.a(Unknown Source)
at com.myapp.myapp.main.ab.run(Unknown Source)
And here is the output:
uncaught exception
java.lang.NullPointerException
at com.myapp.myapp.dbaccess.ZNodeCache.com.myapp.myapp.dbaccess.ZNode getNodeFromCache(long)(Unknown Source)
com.myapp.myapp.dbaccess.ZRoot getRootFromCache()
com.myapp.myapp.dbaccess.ZNode getNodeFromDb(long,boolean)
com.myapp.myapp.dbaccess.ZNode$Array getChildrenForExport(com.myapp.myapp.dbaccess.ZNode)
... many more ...
at com.myapp.myapp.dbaccess.XmlImport.com.myapp.myapp.dbaccess.XmlImport$Results importFile(java.lang.String)(Unknown Source)
void _doImport(java.io.InputStream,com.myapp.myapp.dbaccess.XmlImport$Results)
void importFile(java.io.InputStream)
void importNode(org.xmlpull.v1.XmlPullParser,com.myapp.myapp.dbaccess.ZNode)
... many more ...
at com.myapp.myapp.dbaccess.XmlImport.com.myapp.myapp.dbaccess.XmlImport$Results importFile(java.lang.String)(Unknown Source)
void _doImport(java.io.InputStream,com.myapp.myapp.dbaccess.XmlImport$Results)
void importFile(java.io.InputStream)
void importNode(org.xmlpull.v1.XmlPullParser,com.myapp.myapp.dbaccess.ZNode)
... many more ...
at com.myapp.myapp.main.MainActivity$3.void run()(Unknown Source)
I must be missing another configuration parameter; any ideas?
Turns out the answer is in the Android documentation (believe it or not). I guess I missed it the first time around. You need to specify the source file, like this:
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
The renamsesourcefileattribute will cause all source files to have the name SourceFile (or whatever you put). "retrace" doesn't care what the source file name is, but if you leave it out, it decides to ignore the line numbers.
This goes in proguard-project.txt which, if you're using Android Studio, you'll find in "your project".app.