并非所有的Kotlin异常都在crashlytics中显示

时间:2018-12-17 14:51:52

标签: android kotlin proguard

我加入了一个正在进行的项目,该项目使用Proguard。 由于Proguard,我已经遇到了一些问题,我解决了它,因为行号和类名在crashlytics中无法正确显示

我现在的问题是,我看到正确的行和类名,但唯一的例外是Kotlin.b

Fatal Exception Kotlin.b

缺少什么可以显示正确的异常,并且Proguard是否具有此功能

这是我的Proguard文件,如果我的Proguard文件有问题,我通常会提出建议,因为这是我第一次使用它

-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

1 个答案:

答案 0 :(得分:1)

我发现使用Proguard时,必须为自定义异常添加`-keep' 我想知道这是否是问题并且无法解决,所以我添加了

-keep public class * extends java.lang.Exception

现在,Cotlytics中显示了Kotlin异常