1
0
mirror of https://github.com/etesync/android synced 2025-01-11 16:21:10 +00:00

Add ACRA for crash reporting.

This will make it easier to identify and fix crashes.

Until now we relied on user to automatically figure out if the app has
crashed and gather debug info manually. This didn't work well,
especially in places like "import" where they just assumed the import
finished successfully if there was a crash.

This change makes it so whenever there's a crash, the email app is
opened with a template email and the stack trace attached.

This should make it easier for us to detect and fix issues.

Important to note: nothing is sent automatically.
This commit is contained in:
Tom Hacohen 2018-01-19 14:59:12 +00:00
parent 16e0a57f67
commit b8299a81ce
3 changed files with 25 additions and 1 deletions

View File

@ -111,6 +111,10 @@ android {
} }
dependencies { dependencies {
def acraVersion = '5.0.1'
implementation "ch.acra:acra-mail:$acraVersion"
implementation "ch.acra:acra-toast:$acraVersion"
compile project(':cert4android') compile project(':cert4android')
compile project(':ical4android') compile project(':ical4android')
compile project(':vcard4android') compile project(':vcard4android')

View File

@ -35,6 +35,7 @@ import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Log; import android.util.Log;
import android.widget.Toast;
import com.etesync.syncadapter.log.LogcatHandler; import com.etesync.syncadapter.log.LogcatHandler;
import com.etesync.syncadapter.log.PlainTextFormatter; import com.etesync.syncadapter.log.PlainTextFormatter;
@ -50,6 +51,10 @@ import com.etesync.syncadapter.ui.AccountsActivity;
import com.etesync.syncadapter.utils.HintManager; import com.etesync.syncadapter.utils.HintManager;
import com.etesync.syncadapter.utils.LanguageUtils; import com.etesync.syncadapter.utils.LanguageUtils;
import org.acra.ACRA;
import org.acra.annotation.AcraCore;
import org.acra.annotation.AcraMailSender;
import org.acra.annotation.AcraToast;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import java.io.File; import java.io.File;
@ -76,7 +81,11 @@ import lombok.Cleanup;
import lombok.Getter; import lombok.Getter;
import okhttp3.internal.tls.OkHostnameVerifier; import okhttp3.internal.tls.OkHostnameVerifier;
@AcraCore(buildConfigClass = BuildConfig.class)
@AcraMailSender(mailTo = "reports@etesync.com",
reportFileName = "ACRA-report.stacktrace.json")
@AcraToast(resText = R.string.crash_message,
length = Toast.LENGTH_LONG)
public class App extends Application { public class App extends Application {
public static final String public static final String
DISTRUST_SYSTEM_CERTIFICATES = "distrustSystemCerts", DISTRUST_SYSTEM_CERTIFICATES = "distrustSystemCerts",
@ -133,6 +142,14 @@ public class App extends Application {
loadLanguage(); loadLanguage();
} }
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
private void loadLanguage() { private void loadLanguage() {
@Cleanup ServiceDB.OpenHelper serviceDB = new ServiceDB.OpenHelper(this); @Cleanup ServiceDB.OpenHelper serviceDB = new ServiceDB.OpenHelper(this);
String lang = new Settings(serviceDB.getReadableDatabase()).getString(App.FORCE_LANGUAGE, null); String lang = new Settings(serviceDB.getReadableDatabase()).getString(App.FORCE_LANGUAGE, null);

View File

@ -21,6 +21,9 @@
<string name="please_wait">Please wait …</string> <string name="please_wait">Please wait …</string>
<string name="send">Send</string> <string name="send">Send</string>
<!-- Crash -->
<string name="crash_message">EteSync has crashed, please send stack trace to developers.</string>
<!-- tourguide --> <!-- tourguide -->
<string name="tourguide_title">Did you know?</string> <string name="tourguide_title">Did you know?</string>