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.
pull/29/head
Tom Hacohen 6 years ago
parent 16e0a57f67
commit b8299a81ce

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

@ -35,6 +35,7 @@ import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.widget.Toast;
import com.etesync.syncadapter.log.LogcatHandler;
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.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 java.io.File;
@ -76,7 +81,11 @@ import lombok.Cleanup;
import lombok.Getter;
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 static final String
DISTRUST_SYSTEM_CERTIFICATES = "distrustSystemCerts",
@ -133,6 +142,14 @@ public class App extends Application {
loadLanguage();
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
private void loadLanguage() {
@Cleanup ServiceDB.OpenHelper serviceDB = new ServiceDB.OpenHelper(this);
String lang = new Settings(serviceDB.getReadableDatabase()).getString(App.FORCE_LANGUAGE, null);

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

Loading…
Cancel
Save