Problem with file provider class

Hello,
Can anyone help me with this problem?

I am trying to open a single pdf file using the FileProvider class. I have seen many similar questions, but have not been able to resolve the issue.

If I try to run an application without a provider tag in AndroidManifest.xml, I got this error: java.lang.ClassNotFoundException: android.support.v4.content.FileProvider. Otherwise, the application crashes on start.

Here is my Intent message:

        using (var intentClass = new AndroidJavaClass("android.content.Intent"))
        {
            using (var intentObject = new AndroidJavaObject("android.content.Intent", intentClass.GetStatic<string>("ACTION_VIEW")))
            {
                using (var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
                {
                    using (AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
                    {
                        AndroidJavaObject unityContext = currentActivity.Call<AndroidJavaObject>("getApplicationContext");

                        string packageName = unityContext.Call<string>("getPackageName");
                        string authority = packageName + ".fileprovider";

                        int FLAG_ACTIVITY_NEW_TASK = intentObject.GetStatic<int>("FLAG_ACTIVITY_NEW_TASK");
                        int FLAG_GRANT_READ_URI_PERMISSION = intentObject.GetStatic<int>("FLAG_GRANT_READ_URI_PERMISSION");

                        AndroidJavaObject fileObj = new AndroidJavaObject("java.io.File", uri);
                        AndroidJavaClass fileProvider = new AndroidJavaClass("android.support.v4.content.FileProvider");
                        AndroidJavaObject javaUri = fileProvider.CallStatic<AndroidJavaObject>("getUriForFile", unityContext, authority, fileObj);

                        intentObject.Call<AndroidJavaObject>("setDataAndType", javaUri, "application/vnd.android.package-archive");
                        intentObject.Call<AndroidJavaObject>("addFlags", FLAG_ACTIVITY_NEW_TASK);
                        intentObject.Call<AndroidJavaObject>("addFlags", FLAG_GRANT_READ_URI_PERMISSION);

                        try
                        {
                            currentActivity.Call("startActivity", intentObject);
                        }
                        catch (Exception e)
                        {
                            Debug.LogException(e);
                        }
                    }
                }

            }
        }

AndroidManifest.xml, provider tag:

    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="com.unity3d.player.fileprovider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
    </provider>

file_paths.xml:

<files-path name="my_docs" path="docs/"/>
<external-files-path name="my_documents" path="Documents" /> 
<external-path name="external_files" path="."/>

Hello! I think it’s too late for answer, but i left my answer just in case of need it.
I had exactly same problem and solved(Apply androidmanifest.xml and crash) .
But my androidmanifest.xml settings are littlebit different because i used androidX so you gotta aware of it.

Steps :

  1. PlayerSettings → Android → Publishing Settings → Custom Main Gradle Template checked on.
    Or Use Gradle file if you already have.

  2. add this :
    dependencies
    {
    implementation ‘androidx.core:core:1.0.1’
    }

  3. PlayerSettings → Android → Publishing Settings → Custom Gradle Properties Template checked on.
    Or use gradle.properties file if you have.

  4. add this :
    android.useAndroidX = true

The point is that you need to add dependencies related to FileProvider.

I hope this will be helped.