本文介绍了Crashlytics与Proguard一起崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了面料在其文档中要求的所有内容:

I did everything that fabric ask in their documentation:

-renamesourcefileattribute SourceFile
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

但仍然出现此错误:

此外:构建gradle:

In addition:build gradle:

dependencies {
    // The Fabric Gradle plugin uses an open ended version to react
    // quickly to Android tooling updates
    classpath 'io.fabric.tools:gradle:1.21.7'
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
    transitive = true;
}
compile('com.crashlytics.sdk.android:answers:1.3.8@aar') {
    transitive = true;
}
apply plugin: 'io.fabric'

buildTypes {
    release {
        signingConfig signingConfigs.release
        minifyEnabled true
        shrinkResources true
        proguardFiles 'proguard-rules.pro'
    }

我的活动:

public class BaseActivity extends AppCompatActivity{

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
        Fabric.with(this, new Answers(), new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build());
    }
}

也在Twitter论坛中打开了问题:
https://twittercommunity.com/t/e -answers-failed-submit-events-task/72921/3

Opened issue in Twitter forum too:
https://twittercommunity.com/t/e-answers-failed-to-submit-events-task/72921/3

推荐答案

最后,我发现了我的问题.我以前没有看到它,但是问题是Thread.UncaughtExceptionHandler.
应该是在初始化Fabric crashlytics之后,而之前只有一行.

Finaly i found my problem. I didn't see it before but, Thread.UncaughtExceptionHandler was the problem.
It should be after the initialization of fabric crashlytics while it was one line before.

我通过以下代码解决了该问题:

I solved it by this code:

   @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Order is important!
        // First, start Crashlytics
        Fabric.with(this, new Answers(), new Crashlytics.Builder().core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build()).build());

        // Second, set custom UncaughtExceptionHandler
        Thread.UncaughtExceptionHandler mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
        ExceptionHandler exceptionHandler = new ExceptionHandler(this, mDefaultUEH);
        Thread.setDefaultUncaughtExceptionHandler(exceptionHandler);
}

这篇关于Crashlytics与Proguard一起崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 04:46
查看更多