https://www.zoftino.com/fireabase-crashlytics-android-crash-reporting
MainActivity
https://github.com/firebase/snippets-android/blob/d97dd647ff39f9b9fe2f7163a43d7d8374f74549/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/MainActivity.java#L62-L62
//crashlytics message Crashlytics.log("After adding or updating notes"); Crashlytics.log(2, TAG, "After adding or updating notes"); //crashlytics key and value paris if(editNotesFile != null){ Crashlytics.setString("updating notes", editNotesFile); }else{ Crashlytics.setString("adding notes", notesNameET.getText().toString()); } //adding user identity to crash report Crashlytics.setUserIdentifier(user.getDisplayName());
=================
try { notesBytes = notes.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { Log.e(TAG, "Error encoding file", e); Crashlytics.logException(e); }
MainActivity
https://github.com/firebase/snippets-android/blob/d97dd647ff39f9b9fe2f7163a43d7d8374f74549/crashlytics/app/src/main/java/com/google/firebase/example/crashlytics/MainActivity.java#L62-L62
//crashlytics message Crashlytics.log("After adding or updating notes"); Crashlytics.log(2, TAG, "After adding or updating notes"); //crashlytics key and value paris if(editNotesFile != null){ Crashlytics.setString("updating notes", editNotesFile); }else{ Crashlytics.setString("adding notes", notesNameET.getText().toString()); } //adding user identity to crash report Crashlytics.setUserIdentifier(user.getDisplayName());
=================
try { notesBytes = notes.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { Log.e(TAG, "Error encoding file", e); Crashlytics.logException(e); }
public void setKeysBasic(String key) { | |
// [START crash_set_keys_basic] | |
Crashlytics.setString(key, "foo" /* string value */); | |
Crashlytics.setBool(key, true /* boolean value */); | |
Crashlytics.setDouble(key, 1.0 /* double value */); | |
Crashlytics.setFloat(key, 1.0f /* float value */); | |
Crashlytics.setInt(key, 1 /* int value */); | |
// [END crash_set_keys_basic] | |
} | |
public void resetKey() { | |
// [START crash_re_set_key] | |
Crashlytics.setInt("current_level", 3); | |
Crashlytics.setString("last_UI_action", "logged_in"); | |
// [END crash_re_set_key] | |
} | |
public void logReportAndPrint() { | |
// [START crash_log_report_and_print] | |
Crashlytics.log(Log.DEBUG, "tag", "message"); | |
// [END crash_log_report_and_print] | |
} | |
public void logReportOnly() { | |
// [START crash_log_report_only] | |
Crashlytics.log("message"); | |
// [END crash_log_report_only] | |
} | |
public void enableAtRuntime() { | |
// [START crash_enable_at_runtime] | |
Fabric.with(this, new Crashlytics()); | |
// [END crash_enable_at_runtime] | |
} | |
public void setUserId() { | |
// [START crash_set_user_id] | |
Crashlytics.setUserIdentifier("user123456789"); | |
// [END crash_set_user_id] | |
} | |
public void methodThatThrows() throws Exception { | |
throw new Exception(); | |
} | |
public void logCaughtEx() { | |
// [START crash_log_caught_ex] | |
try { | |
methodThatThrows(); | |
} catch (Exception e) { | |
Crashlytics.logException(e); | |
// handle your exception here | |
} | |
// [END crash_log_caught_ex] | |
} | |
public void enableDebugMode() { | |
// [START crash_enable_debug_mode] | |
final Fabric fabric = new Fabric.Builder(this) | |
.kits(new Crashlytics()) | |
.debuggable(true) // Enables Crashlytics debugger | |
.build(); | |
Fabric.with(fabric); | |
// [END crash_enable_debug_mode] | |
} | |
public void forceACrash() { | |
// [START crash_force_crash] | |
Button crashButton = new Button(this); | |
crashButton.setText("Crash!"); | |
crashButton.setOnClickListener(new View.OnClickListener() { | |
public void onClick(View view) { | |
Crashlytics.getInstance().crash(); // Force a crash | |
} | |
}); | |
addContentView(crashButton, new ViewGroup.LayoutParams( | |
ViewGroup.LayoutParams.MATCH_PARENT, | |
ViewGroup.LayoutParams.WRAP_CONTENT)); | |
// [END crash_force_crash] | |
} | |