CrashReporter
CrashReporter copied to clipboard
FileUriExposedException
when try to make share we got this exception ... android 8.0 ...it will occur on 7.0 also with build target 25.0.3
is it possible to share trace in any case i'll look into this
You are using a file uri to open the log file. https://github.com/MindorksOpenSource/CrashReporter/blob/5cfdaa97680088d3e8b79108568a7d0c776b67f0/crashreporter/src/main/java/com/balsikandar/crashreporter/ui/LogMessageActivity.java#L30
This is not allowed on Android 7+ anymore: https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed
Was this fixed in the library
How to fix
Create an xml file(Path: res\xml) provider_paths.xml
Add a Provider in AndroidManifest.xml
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
If you are using androidx, the FileProvider path should be:
android:name="androidx.core.content.FileProvider"
and replace
Uri uri = Uri.fromFile(fileImagePath); to
Uri uri = FileProvider.getUriForFile(MainActivity.this, BuildConfig.APPLICATION_ID + ".provider",fileImagePath); While you're including the URI with an Intent make sure to add below line:
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Got the same issue (V1.1.0 on OS 9.0) :
AndroidRuntime E FATAL EXCEPTION: main E android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.your-app.pkgname/files/crashReports/2020-07-27%2017%3A14%3A53_crash.txt exposed beyond app through ClipData.Item.getUri() E at android.os.StrictMode.onFileUriExposed(StrictMode.java:1978) E at android.net.Uri.checkFileUriExposed(Uri.java:2371) E at android.content.ClipData.prepareToLeaveProcess(ClipData.java:963) E at android.content.Intent.prepareToLeaveProcess(Intent.java:10228) E at android.content.Intent.prepareToLeaveProcess(Intent.java:10234) E at android.content.Intent.prepareToLeaveProcess(Intent.java:10213) E at android.app.Instrumentation.execStartActivity(Instrumentation.java:1669) E at android.app.Activity.startActivityForResult(Activity.java:4586) E at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActiv ity.java:767) E at android.app.Activity.startActivityForResult(Activity.java:4544) E at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActiv ity.java:754) E at android.app.Activity.startActivity(Activity.java:4905) E at android.app.Activity.startActivity(Activity.java:4873) E at com.balsikandar.crashreporter.ui.LogMessageActivity.shareCrashReport(LogMes sageActivity.java:82) E at com.balsikandar.crashreporter.ui.LogMessageActivity.onOptionsItemSelected(L ogMessageActivity.java:70) E at android.app.Activity.onMenuItemSelected(Activity.java:3543)