Is it possible to add a property tag to android manifest?

Hello, I’m trying to share an image from my app, using the android FileProvider class. I do not want to make a plugin, since I already took the time to write the equivalent code with AndroidJavaObjects. So far, everything works ok, but as the referenced FileProvider docs show, you need to add some xml data in 2 places.

I need to define the paths that I’ll be allowed to share within my app, using xml file like this:

<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="share_folder" path=""/>
</paths>    

This file is saved at Plugins/Android/res/xml/sharepaths.xml and while using the res/ folder is deprecated, it also still works, giving a warning message as this forum thread says.

Now, this is the part I can’t figure out To link that sharepaths.xml file with my app, I need to add one entry to my manifest’s < application > section, like the following

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

But the app doesn’t have an explicit manifest file, and since I don’t understand them very well I’d prefer to let Unity keep handling it, if possible. I know Unity can merge the manifests of other plugins too, so is there some folder or format I can use to get this one tag inserted into my manifest?

Hopefully, it’s not that hard, but I can’t seem to find the right Google Search Terms to get to the answer (just lots of questions about plugins not playing nice with each other).

Thanks!

Edit: idk if this helps or not, but when I tried to copy Unity’s generated androidmanifest.xml into my Plugins/Android/ dir, and added my tag, the app won’t run. It compiles, deploys, and then immediately crashes. Logcat has the following error, which I would guess means that there’s some duplication of my activity happening?

E/AndroidRuntime(11057): java.lang.RuntimeException: Unable to
instantiate activity
ComponentInfo{com.mycompany.hellounity/com.mycompany.hellounity.UnityPlayerActivity}:
java.lang.ClassNotFoundException:
Didn’t find class
“com.mycompany.hellounity.UnityPlayerActivity”
on path: DexPathList[[zip file
“/data/app/com.mycompany.hellounity-1.apk”],nativeLibraryDirectories=[/data/app-lib/com.mycompany.hellounity-1,
/vendor/lib, /system/lib]]

Ok I think I figured it out, when I saw that in StagingArea, Unity was actually making an AndroidManifest-main.xml in addition to the actual one. This was my manifest before other plugins’ stuff was added, so I copied that into Plugins/Android/AndroidManifest.xml and placed my < provider > in there. After that everything worked great. So in case that was a little unclear, here are the shortened steps I took

  1. With no AndroidManifest.xml file in the root of Plugins/Android, do an APK build.
  2. Check the Temp/StagingArea folder for one or more Unity-generated AndroidManifest- .xml files, and find the smallest one with the unity-activity definition (for me, AndroidManifest-main.xml)
  3. Copy the AndroidManifest-main.xml to Plugins/Android/AndroidManifest.xml - now unity will use this as your “main” manifest.
  4. Add whatever you need to add into the Plugins/Android/AndroidManifest.xml
  5. Do another build, and verify your changes propagate back into the Temp/StagingArea files

Hope this helps someone.