Search code examples
androidkotlinproguard

Kotlin exceptions not all shown in crashlytics


I joined an ongoing project, this project uses Proguard. I already had some problems because of Proguard and I solved it as line numbers and class names wasn't showing correctly in crashlytics

My problem now, that I see the correct line and class name but the exception is just Kotlin.b

Fatal Exception Kotlin.b

What is missing to show the correct exception, and does Proguard has something with this or not

Here is my Proguard file, I am open for suggestions in general if there is something wrong with my Proguard file as it is my first time to use it

-optimizationpasses 1
-dontpreverify
-verbose

-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
-keep public class com.android.vending.licensing.ILicensingService
-keep public class android.content.Context
-keep class com.gauravbhola.ripplepulsebackground.RipplePulseLayout$RippleView { *; }

#-keep,includedescriptorclasses public class androidx.** { *; }
#-keep,includedescriptorclasses public class android.support.** { *; }
#-keep,includedescriptorclasses public class com.google.** { *; }
-keep,includedescriptorclasses public class io.fabric.sdk.** { *; }

# Keep AppMeasurement
-keepclasseswithmembers class * {
    public static com.google.android.gms.measurement.AppMeasurement getInstance (android.content.Context);
}
-dontwarn com.google.**
-dontwarn android.support.**
-dontwarn androidx.**
-dontwarn io.fabric.sdk.**

-optimizations !class/unboxing/enum


-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** v(...);
    public static *** w(...);
    public static *** i(...);
}

# this will fix a force close in ReadingActivity
-keep public class org.jsoup.** {
    public *;
}

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

#skip running ProGuard on Crashlytics
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

# The I2P Java API bundled inside the I2P Android client library contains
# references to javax.naming classes that Android doesn't have. But those
# classes are never used on Android, and it is safe to ignore the warnings.
-dontwarn net.i2p.crypto.CertUtil
-dontwarn org.apache.http.conn.ssl.DefaultHostnameVerifier

-dontwarn org.apache.http.HttpHost

# Needed for okhttp
-dontwarn okio.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault

# there were 11 unresolved references to classes or interfaces
-dontwarn okhttp3.**
# -dontwarn javax.annotation.**
-dontwarn org.conscrypt.**
# A resource is loaded with a relative path so the package of this class must be preserved.
# -keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

# Preserve annotations, line numbers, and source file names
-keepattributes *Annotation*,SourceFile,LineNumberTable

-keepattributes InnerClasses,EnclosingMethod

Solution

  • I found that with using Proguard, you have to add `-keep' for your custom exceptions I wondered if this is the problem and it is not handled, so I added

    -keep public class * extends java.lang.Exception
    

    and now Kotlin exceptions are shown in the Crashlytics