Failed to find configured root that contains

t0s picture t0s · May 29, 2014 · Viewed 11.7k times · Source

I'm getting the following error :

05-29 01:08:02.924: E/AndroidRuntime(5447): FATAL EXCEPTION: IntentService[com.sample.muzeitest.MuzeiClass]
05-29 01:08:02.924: E/AndroidRuntime(5447): java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/com.sample.muzeitest/files/wallpaper0.png
05-29 01:08:02.924: E/AndroidRuntime(5447):     at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:678)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:377)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at com.sample.muzeitest.MuzeiClass.muzeiContentUri(MuzeiClass.java:58)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at com.sample.muzeitest.MuzeiClass.onUpdate(MuzeiClass.java:37)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at com.google.android.apps.muzei.api.MuzeiArtSource.processAndDispatchSubscriberAdded(MuzeiArtSource.java:614)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at com.google.android.apps.muzei.api.MuzeiArtSource.processSubscribe(MuzeiArtSource.java:581)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at com.google.android.apps.muzei.api.MuzeiArtSource.onHandleIntent(MuzeiArtSource.java:539)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at android.os.Looper.loop(Looper.java:137)
05-29 01:08:02.924: E/AndroidRuntime(5447):     at android.os.HandlerThread.run(HandlerThread.java:61)

When I try to use my FileProvider with the muzei app.

I'm having an activity ( which adds some bitmaps from a drawable folder to the /data/data/APP-SPACE-HERE/files/ ) and a class extending the MuzeiArtSource :

public class MuzeiClass extends MuzeiArtSource {


Uri imgUri;


public MuzeiClass() {
    super(MuzeiClass.class.getName());

}


@Override
public void onCreate() {
    super.onCreate();
   // setUserCommands(BUILTIN_COMMAND_ID_NEXT_ARTWORK); // manual switch image

}

@Override
protected void onUpdate(int arg0) {


       imgUri = muzeiContentUri();  


    publishArtwork(new Artwork.Builder()
           .imageUri( imgUri )
           .title("Example image")
           .byline("Unknown person, c. 1980")
//             .viewIntent(new Intent(Intent.ACTION_VIEW,
//                     Uri.parse("http://example")))
           .build());       

}


public Uri muzeiContentUri()    {

    File newFile = new File(getFilesDir(), "wallpaper0.png");
    Uri contentUri = FileProvider.getUriForFile(getApplicationContext(), "com.sample.muzeitest.fileprovider", newFile);


    return contentUri;
}



}

Manifest file contains provider for FileProvider and service tags :

        <service
        android:name="com.sample.muzeitest.MuzeiClass"
        android:label="@string/title_activity_muzei_service"
        android:description="@string/muzei_description"
        android:icon="@drawable/ic_source">
         <intent-filter>
            <action android:name="com.google.android.apps.muzei.api.MuzeiArtSource" />
        </intent-filter>
        <meta-data android:name="color" android:value="#fa0" />
    </service>     


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

I also have this xml file in res/ folder :

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

I made this question yesterday but the problem was about the uri name. I use adb shell to go the specified path /data/data/com.sample.muzeitest/files/wallpaper0.png and I can confirm that files are there saved. Read also some similar questions on SO but none helped.

Answer

dev.shige picture dev.shige · Jul 16, 2014
/data/data/com.sample.muzeitest/files/wallpaper0.png 

means files-path and no sub-directory.

then xml definition is

<files-path name="my_images" path=""  />

files-path#path is files/xxxxx/ <== means xxxxx/

please check it.