Problem with file provider class

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: 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("", uri);
                        AndroidJavaClass fileProvider = new AndroidJavaClass("");
                        AndroidJavaObject javaUri = fileProvider.CallStatic<AndroidJavaObject>("getUriForFile", unityContext, authority, fileObj);

                        intentObject.Call<AndroidJavaObject>("setDataAndType", javaUri, "application/");
                        intentObject.Call<AndroidJavaObject>("addFlags", FLAG_ACTIVITY_NEW_TASK);
                        intentObject.Call<AndroidJavaObject>("addFlags", FLAG_GRANT_READ_URI_PERMISSION);

                            currentActivity.Call("startActivity", intentObject);
                        catch (Exception e)


AndroidManifest.xml, provider tag:

            android:resource="@xml/file_paths" />


<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 :
    implementation ‘androidx.core:core:1.0.1’

  3. PlayerSettings → Android → Publishing Settings → Custom Gradle Properties Template checked on.
    Or use 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.