프로그래밍/android

[android] Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains

-샤리- 2021. 1. 29. 15:28

java.lang.IllegalArgumentException: Failed to find configured root that contains ..

 

targetSdkVersion 30에서 이와 같은 오류가 발생했다. provider_paths.xml에 <files-path name="files" path="."/>만 있었는데, 아래처럼 external-files-path와 external-path를 추가함으로써 해결되었다.

 

AndroidManifest.xml

<provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>

 

res/res/provider_paths.xml

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <files-path name="files" path="."/>
    <external-files-path name="external_files_path" path="." />
    <external-path name="external_files" path="."/>
</paths>