From 2310bec5a94c619fbe255466021cfd13696d67be Mon Sep 17 00:00:00 2001 From: Tim Schneeberger Date: Fri, 13 Dec 2024 20:45:02 +0100 Subject: [PATCH] fix: fixed rare crash on startup --- .../rootlessjamesdsp/MainApplication.kt | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/MainApplication.kt b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/MainApplication.kt index 42634b508..682de6f63 100644 --- a/app/src/main/java/me/timschneeberger/rootlessjamesdsp/MainApplication.kt +++ b/app/src/main/java/me/timschneeberger/rootlessjamesdsp/MainApplication.kt @@ -112,14 +112,23 @@ open class MainApplication : Application(), SharedPreferences.OnSharedPreference // Clean up Cache.cleanup(this) - Timber.plant(FileLoggerTree.Builder() - .withFileName("application.log") - .withDirName(this.cacheDir.absolutePath) - .withMinPriority(Log.VERBOSE) - .withSizeLimit(2 * 1000000) - .withFileLimit(1) - .appendToFile(false) - .build()) + try { + Timber.plant( + FileLoggerTree.Builder() + .withFileName("application.log") + .withDirName(this.cacheDir.absolutePath) + .withMinPriority(Log.VERBOSE) + .withSizeLimit(2 * 1000000) + .withFileLimit(1) + .appendToFile(false) + .build() + ) + } + catch (ex: Exception) { + // Log file creation may fail + Timber.e(ex) + } + Timber.i("====> Application starting up") val dumpFile = File(filesDir, "dump.txt")