We are using the version 6.0.2 of your library and we use the Viewer extension. We also use the lumberjack implementation, not Timber. I'm writing this issue to let you know that when FileProvider is used in the application, a crash occurs when sending a log file by email.
Portion of our build.gradle file:
def lumberjack = "6.0.2"
implementation("com.github.MFlisar.Lumberjack:core:$lumberjack")
implementation("com.github.MFlisar.Lumberjack:implementation-lumberjack:$lumberjack")
implementation("com.github.MFlisar.Lumberjack:logger-console:$lumberjack")
implementation("com.github.MFlisar.Lumberjack:logger-file:$lumberjack")
implementation("com.github.MFlisar.Lumberjack:extension-viewer:$lumberjack")
Simple init:
L.init(LumberjackLogger)
fileLoggingSetup = FileLoggerSetup.Daily(context)
L.plant(FileLogger(fileLoggingSetup))
When we started to use the FileProvider in our application, we needed to add this code block in the AndroidManifest.xml file:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.example.file-provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
And here is the content of the file_paths.xml:
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-files-path
name="pictures"
path="Pictures" />
</paths>
As a result, when we try to share a log file by email, we get this exception:
FATAL EXCEPTION: main
Process: com.example.myapp, PID: 31371
java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.example.myapp/files/shared-files/log_2024_01_15.log
at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:849)
at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:452)
at com.michaelflisar.cachefileprovider.CachedFileProvider$Companion.getCacheFileUri(CachedFileProvider.kt:21)
at com.michaelflisar.feedbackmanager.Feedback.buildIntent(Feedback.kt:36)
at com.michaelflisar.feedbackmanager.Feedback.startEmailChooser(Feedback.kt:59)
at com.michaelflisar.lumberjack.extensions.feedback.ExtensionFeedbackKt.sendFeedback(ExtensionFeedback.kt:34)
at com.michaelflisar.lumberjack.extensions.feedback.ExtensionFeedbackKt.sendFeedback$default(ExtensionFeedback.kt:22)
at com.michaelflisar.lumberjack.extensions.viewer.view.LumberjackViewerActivity.onOptionsItemSelected(LumberjackViewerActivity.kt:171)
Since your library creates a copy of the log file in a folder named "shared-files", I added this path in the file_paths.xml file, like below:
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-files-path
name="pictures"
path="Pictures" />
<files-path
name="shared-files"
path="shared-files/" />
</paths>
Adding the <files-path>
tag did the trick. I'm sharing this just in case you would have a better solution to suggest. Adding this use-case to your documentation could also avoid some headaches to other users.
Good work BTW, we like your lib a lot!