Proguard Stack in Crashlytics
Solution 1
I contact Crashlytics support, and I resolved the problem!
They told me to check Crashlytics.log:
On Linux / Windows: ~/.crashlytics/com.crashlytics.tools/crashlytics.log
On Mac: ~/Library/Caches/com.crashlytics/com.crashlytics.tools/crashlytics.log
Here I saw that:
Crashlytics detected deobfuscation, but did not find a mapping file at /Users/admin/AndroidstudioProjects/MyApp/build/outputs/mapping/release/mapping.txt
So I just changed
-printmapping mapping.txt
to
-printmapping build/outputs/mapping/release/mapping.txt
and it worked!
Tx for you help !
Solution 2
I just have the following 2 lines in my Proguard file for Crashlytics:
-keep class com.crashlytics.** { *; }
-keepattributes SourceFile,LineNumberTable
Juliatzin
Developper / AWS / DevOps / Blockchain Implementing blockchain for secure energy transactions
Updated on June 29, 2022Comments
-
Juliatzin almost 2 years
I have several recurrent logs in Crashlytics that I can't read.
java.lang.NullPointerException at ahm.onClick(SourceFile:239) at android.view.View.performClick(View.java:4212) at android.view.View$PerformClick.run(View.java:17476) 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:5431) at java.lang.reflect.Method.invokeNative(Method.java) 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(NativeStart.java)
AND
java.lang.NullPointerException at com.app.mobile.RutaActivity.a(SourceFile:747) at ahh.run(SourceFile:1055) at java.lang.Thread.run(Thread.java:856)
In the first log, the name of my app's package is never mentioned, so I don't even know where to look for my NPE.
In the second log, I have the FileName (RutaActivity) but when I look at the line number, I see no place for a NPE bug...
How can I do? How can I do in the second log to see the method name instead of a?
My Proguard file:
##---------------Begin: proguard configuration common for all Android apps ---------- -optimizationpasses 5 -dontskipnonpubliclibraryclassmembers -dontpreverify -dump class_files.txt -printseeds seeds.txt -printusage unused.txt -printmapping mapping.txt -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* -allowaccessmodification -renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable, LocalVariableTable,LocalVariableTypeTable -repackageclasses '' -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference -dontnote com.android.vending.licensing.ILicensingService -keep public class * extends android.view.View { public <init>(android.content.Context); public <init>(android.content.Context, android.util.AttributeSet); public <init>(android.content.Context, android.util.AttributeSet, int); public void set*(...); } # Explicitly preserve all serialization members. The Serializable interface # is only a marker interface, so it wouldn't save them. -keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve(); } # Preserve all native method names and the names of their classes. -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclassmembers class * extends android.content.Context { public void *(android.view.View); public void *(android.view.MenuItem); } -keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; } -keepclasseswithmembernames class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembernames class * { public <init>(android.content.Context, android.util.AttributeSet, int); } # Preserve static fields of inner classes of R classes that might be accessed # through introspection. -keepclassmembers class **.R$* { public static <fields>; } ##---------------End: proguard configuration common for all Android apps ---------- ##---------------Begin: proguard configuration for Gson ---------- # Gson uses generic type information stored in a class file when working with fields. Proguard # removes such information by default, so configure it to keep all of it. -keepattributes Signature # Gson specific classes -keep class sun.misc.Unsafe { *; } # Application classes that will be serialized/deserialized over Gson -keep class com.google.gson.examples.android.model.** { *; } ##---------------End: proguard configuration for Gson ---------- ##---------------Begin proguard configuration for Google Maps -------------------- -keep class com.google.android.gms.** { *; } -dontwarn com.google.android.gms.** -keep class org.** { *; } -keep class * extends java.util.ListResourceBundle { protected Object[][] getContents(); } -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { public static final *** NULL; } -keepnames @com.google.android.gms.common.annotation.KeepName class * -keepclassmembernames class * { @com.google.android.gms.common.annotation.KeepName *; } -renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable ##---------------End proguard configuration for Google Maps -------------------- ##---------------Begin proguard configuration for my libs ----------------------- -keep class com.todddavies.components.progressbar.** { *; } -dontwarn com.todddavies.components.progressbar.** -dontwarn org.apache.** -keepclassmembers class * implements android.os.Parcelable { static ** CREATOR; } #Disable logging -assumenosideeffects class android.util.Log { public static *** d(...); public static *** v(...); public static *** i(...); } -keep class com.app.mobile.vo.Captura { *; } -keep class com.app.mobile.vo.Formulario { *; } -keep class com.app.mobile.vo.Metrica { *; } -keep class com.app.mobile.vo.Pdv { *; } -keep class com.app.mobile.vo.Proyecto { *; } -keep class com.app.mobile.vo.Producto { *; } -keep class com.app.mobile.vo.Nota { *; } -keep class com.app.mobile.vo.Encuesta { *; } -keep class com.app.mobile.vo.Usuario { *; } -keep class com.app.mobile.vo.BambooPerf { *; } -keep class com.app.mobile.vo.SoftwareVersion { *; }
-
njzk2 almost 9 yearsuse
retrace.jar
with the mapping file from proguard to recreate a readable stacktrace : proguard.sourceforge.net/manual/retrace/examples.html -
njzk2 almost 9 yearsalso, crashlytics is supposed to be able to read stacktraces, provided that you give it the mappings.txt file with the apk
-
Alexizamerican almost 9 yearsHave you tried removing
-printmapping mapping.txt
from your Proguard file?
-
-
Ganesh Krishnan almost 9 yearsThanks for update. This issue was driving me crazy as I had setup everything but still the code was obfuscated on the crashlytics site
-
Renan Ferrari over 8 yearsThis is the right answer, but I should add that it doesn't work if you're using product flavors. Deleting the -printmapping line should be a better option in this case.
-
Dharmendra over 7 yearsWe should remove -printmapping from proguard file. reference link docs.fabric.io/android/crashlytics/dex-and-proguard.html,
-
algrid about 6 years@Dharmendra wouldn't it prevent us from having proper source file names if we use "-renamesourcefileattribute SourceFile" at the same time?