1

I need to use 2 file providers for my app.

I have tried the quick fix suggested in this answer:

https://stackoverflow.com/a/42989182/7952427

But the app crashes.

I know that the second provider is causing this exception/crash because when i remove it, the app doesn't crash anymore.

In Manifest:

<provider
  android:name="android.support.v4.content.FileProvider"
        android:authorities="com.example.android.fileproviderTestLyb"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths">
        </meta-data>
    </provider>
    <provider
        android:name=".MyFileProvider"
        android:authorities="com.example.android.fileprovider2"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS_video"
            android:resource="@xml/video_path">
        </meta-data>
    </provider>

The File Provider class:

import android.support.v4.content.FileProvider;
public class MyFileProvider  extends FileProvider{
}

Can anyone help me understand why? Do i need to add something to MyFileProvider class?

3
  • "And i'm getting this exception" -- are you sure that is coming from your process, and is not just some other stack trace from some other app that is showing up in LogCat? FileProvider has nothing to do with windows. Commented Jun 30, 2017 at 12:42
  • Yes, you are right. I'm new to Android, sorry :/ I've edited my question. Commented Jun 30, 2017 at 12:48
  • Well, if your app is crashing, there will be a stack trace for that crash in LogCat. It just has to be one from a process associated with what's going on Commented Jun 30, 2017 at 12:53

1 Answer 1

2

Replace:

android.support.FILE_PROVIDER_PATHS_video

with:

android.support.FILE_PROVIDER_PATHS

FileProvider will definitely crash if you do not provide a android.support.FILE_PROVIDER_PATHS <meta-data> element.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! That worked! I've accepted your answer but it doesn't show because i have less than 15 reputation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.