Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ follow [https://changelog.md/](https://changelog.md/) guidelines.

## [Unreleased]

## [53.5] - 2025-06-27

### FIXED

- Error logging and reporting logic.

## [53.4] - 2025-05-29

### CHANGED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,66 +10,72 @@ class MuunTree : Timber.DebugTree() {
* Log a message, taking steps to enrich and report errors.
* Automatically infers the tag from the calling class (See Timber.DebugTree).
*/
override fun log(priority: Int, error: Throwable?, message: String?, vararg args: Any?) {
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
// For low priority logs, we don't have any special treatment:
if (priority < Log.INFO) {
sendToLogcat(priority, message, error)
sendToLogcat(priority, tag, message, t)
return
}

when (priority) {
Log.INFO -> {
sendToLogcat(Log.INFO, "Breadcrumb: ${message!!}", null)
sendToLogcat(Log.INFO, tag, "Breadcrumb: $message", null)
@Suppress("DEPRECATION") // I know. These are the only allowed usages.
Crashlytics.logBreadcrumb(message)
}

Log.WARN -> {
sendToLogcat(Log.WARN, message!!, null)
sendToLogcat(Log.WARN, tag, message, null)
@Suppress("DEPRECATION") // I know. These are the only allowed usages.
Crashlytics.logBreadcrumb("Warning: $message")
}

else -> { // Log.ERROR && Log.ASSERT
sendCrashReport(message, error)
sendCrashReport(tag, message, t)
}
}
}

private fun sendCrashReport(message: String?, error: Throwable?) {
private fun sendCrashReport(tag: String?, message: String, error: Throwable?) {
try {
sendPreparedCrashReport(message, error)
sendPreparedCrashReport(tag, message, error)

} catch (crashReportingError: Throwable) {
sendFallbackCrashReport(message, error, crashReportingError)
sendFallbackCrashReport(tag, message, error, crashReportingError)
}
}

private fun sendPreparedCrashReport(message: String?, error: Throwable?) {
private fun sendPreparedCrashReport(tag: String?, message: String, error: Throwable?) {
val report = CrashReportBuilder.build(message, error)

if (LoggingContext.sendToCrashlytics) {
Crashlytics.reportError(report)
}

sendToLogcat(Log.ERROR, "${report.message} ${report.metadata}", report.error)
sendToLogcat(Log.ERROR, tag, "${report.message} ${report.metadata}", report.error)
}

private fun sendFallbackCrashReport(
message: String?,
tag: String?,
message: String,
error: Throwable?,
crashReportingError: Throwable,
) {

sendToLogcat(Log.ERROR, "During error processing", crashReportingError)
sendToLogcat(Log.ERROR, message, error)
sendToLogcat(Log.ERROR, tag, "During error processing", crashReportingError)
sendToLogcat(Log.ERROR, tag, message, error)

if (LoggingContext.sendToCrashlytics) {
Crashlytics.reportReportingError(message, error, crashReportingError)
}
}

private fun sendToLogcat(priority: Int, message: String?, error: Throwable?) {
if (LoggingContext.sendToLogcat) {
super.log(priority, message, error)
private fun sendToLogcat(priority: Int, tag: String?, message: String, error: Throwable?) {
// No matter what env or kind or build this is, we want to log errors ;)
if (LoggingContext.sendToLogcat || priority >= Log.ERROR) {
// Named params are required to avoid calling new method overload :s
// log(priority: Int, message: String?, vararg args: Any?)
super.log(priority = priority, tag = tag, message = message, t = error)
}
}
}
4 changes: 2 additions & 2 deletions android/apolloui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ android {
applicationId "io.muun.apollo"
minSdk 19
targetSdk 34
versionCode 1304
versionName "53.4"
versionCode 1305
versionName "53.5"

// Needed to make sure these classes are available in the main DEX file for API 19
// See: https://spin.atomicobject.com/2018/07/16/support-kitkat-multidex/
Expand Down