Search code examples
javaandroidandroid-contentprovider

Unresolved Class 'FileProvider' in manifest.xml (Android Java)


I am building my first Java application. Its functionality includes taking camera images and saving them along with saving 'Project' information locally for said images to be associated with.

I believe I need to include the FileProvider to my code:

        <provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="devkit.blade.vuzix.com.blade_template_app"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_path"></meta-data>
        </provider>

In the above XML .FileProvider is not resolving and so I cant build the app. What's the problem here?

Also for context @xml/provider_path references this file:

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <external-path name="/storage/emulated/0" path="."/>
</paths>

Solution

  • Adding this to my build.grade (app module) allowed it to be referenced correctly. If you are required to use API level 27 (pre androidX) this is the way!

    implementation 'com.android.support:support-core-utils:27.0.0'