From 1b9f5989efff651c3a99eacfacab2015cc75a5a4 Mon Sep 17 00:00:00 2001 From: Stypox Date: Tue, 28 Jul 2020 10:45:48 +0200 Subject: [PATCH] Fix empty stacktrace in bug report ACRA has to be initialized after MultiDex https://github.com/ACRA/acra/issues/619 https://github.com/ACRA/acra/wiki/Troubleshooting-Guide#legacy-multidex --- app/src/debug/java/org/schabi/newpipe/DebugApp.kt | 12 ++++++------ app/src/main/java/org/schabi/newpipe/App.java | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/src/debug/java/org/schabi/newpipe/DebugApp.kt b/app/src/debug/java/org/schabi/newpipe/DebugApp.kt index 5cfde80b8..9ea3bdabe 100644 --- a/app/src/debug/java/org/schabi/newpipe/DebugApp.kt +++ b/app/src/debug/java/org/schabi/newpipe/DebugApp.kt @@ -1,6 +1,5 @@ package org.schabi.newpipe -import android.content.Context import androidx.multidex.MultiDex import androidx.preference.PreferenceManager import com.facebook.stetho.Stetho @@ -11,11 +10,6 @@ import okhttp3.OkHttpClient import org.schabi.newpipe.extractor.downloader.Downloader class DebugApp : App() { - override fun attachBaseContext(base: Context) { - super.attachBaseContext(base) - MultiDex.install(this) - } - override fun onCreate() { super.onCreate() initStetho() @@ -34,6 +28,12 @@ class DebugApp : App() { return downloader } + override fun initACRA() { + // install MultiDex before initializing ACRA + MultiDex.install(this) + super.initACRA() + } + private fun initStetho() { // Create an InitializerBuilder val initializerBuilder = Stetho.newInitializerBuilder(this) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 33d77ea47..64c1fdb1c 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -77,7 +77,6 @@ public class App extends Application { @Override protected void attachBaseContext(final Context base) { super.attachBaseContext(base); - initACRA(); } @@ -200,7 +199,11 @@ public class App extends Application { .build(); } - private void initACRA() { + /** + * Called in {@link #attachBaseContext(Context)} after calling the {@code super} method. + * Should be overridden if MultiDex is enabled, since it has to be initialized before ACRA. + */ + protected void initACRA() { try { final CoreConfiguration acraConfig = new CoreConfigurationBuilder(this) .setReportSenderFactoryClasses(REPORT_SENDER_FACTORY_CLASSES)