Crashlytics 与混淆器崩溃
Crashlytics crash with proguard
我做了他们文档中 fabric 要求的所有事情:
-renamesourcefileattribute SourceFile
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
但仍然出现此错误:
E/Answers: Failed to submit events task
java.util.concurrent.RejectedExecutionException: Task
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@d2d2a84
rejected from
java.util.concurrent.ScheduledThreadPoolExecutor@6b49897[Shutting
down, pool size = 1, active threads = 0, queued tasks = 1, completed
tasks = 5]
at
java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2014)
at
java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:794)
at
java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:302)
at
java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:527)
at
java.util.concurrent.ScheduledThreadPoolExecutor.submit(ScheduledThreadPoolExecutor.java:626)
at
java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:594)
at
com.crashlytics.android.answers.AnswersEventsHandler.executeAsync(SourceFile:182)
at
com.crashlytics.android.answers.AnswersEventsHandler.processEvent(SourceFile:168)
at
com.crashlytics.android.answers.AnswersEventsHandler.processEventAsync(SourceFile:44)
at
com.crashlytics.android.answers.SessionAnalyticsManager.onLifecycle(SourceFile:128)
at
com.crashlytics.android.answers.AnswersLifecycleCallbacks.onActivityStopped(SourceFile:43)
at io.fabric.sdk.android.c.onActivityStopped(SourceFile:126)
at
android.app.Application.dispatchActivityStopped(Application.java:232)
at android.app.Activity.onStop(Activity.java:1620)
at android.support.v4.app.FragmentActivity.onStop(SourceFile:616)
at android.support.v7.app.AppCompatActivity.onStop(SourceFile:172)
at
android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1279)
at android.app.Activity.performStop(Activity.java:6395)
at
android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3824)
at
android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3883)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1417)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5461)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
另外:
构建 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'
}
我的activity:
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-to-submit-events-task/72921/3
终于找到我的问题了。我之前没有看到它,但是 Thread.UncaughtExceptionHandler
是问题所在。
应该是在fabric crashlytics初始化之后,之前是一行。
我用这段代码解决了:
@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);
}
我做了他们文档中 fabric 要求的所有事情:
-renamesourcefileattribute SourceFile
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
但仍然出现此错误:
E/Answers: Failed to submit events task java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@d2d2a84 rejected from java.util.concurrent.ScheduledThreadPoolExecutor@6b49897[Shutting down, pool size = 1, active threads = 0, queued tasks = 1, completed tasks = 5] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2014) at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:794) at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:302) at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:527) at java.util.concurrent.ScheduledThreadPoolExecutor.submit(ScheduledThreadPoolExecutor.java:626) at java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:594) at com.crashlytics.android.answers.AnswersEventsHandler.executeAsync(SourceFile:182) at com.crashlytics.android.answers.AnswersEventsHandler.processEvent(SourceFile:168) at com.crashlytics.android.answers.AnswersEventsHandler.processEventAsync(SourceFile:44) at com.crashlytics.android.answers.SessionAnalyticsManager.onLifecycle(SourceFile:128) at com.crashlytics.android.answers.AnswersLifecycleCallbacks.onActivityStopped(SourceFile:43) at io.fabric.sdk.android.c.onActivityStopped(SourceFile:126) at android.app.Application.dispatchActivityStopped(Application.java:232) at android.app.Activity.onStop(Activity.java:1620) at android.support.v4.app.FragmentActivity.onStop(SourceFile:616) at android.support.v7.app.AppCompatActivity.onStop(SourceFile:172) at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1279) at android.app.Activity.performStop(Activity.java:6395) at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3824) at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3883) at android.app.ActivityThread.-wrap5(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1417) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5461) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
另外: 构建 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'
}
我的activity:
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-to-submit-events-task/72921/3
终于找到我的问题了。我之前没有看到它,但是 Thread.UncaughtExceptionHandler
是问题所在。
应该是在fabric crashlytics初始化之后,之前是一行。
我用这段代码解决了:
@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);
}