Failed to find provider info for 'ContentProvider'
Asked Answered
S

7

31

I have a problem that I just cannot figure out. I am using Eclipse to create my own Content Provider but keep getting the following error:

[..] ERROR/ActivityThread(1051): Failed to find provider info for my.package.provider.countrycontentprovider

Code found here: http://codepad.org/Rx00HjHd

Main parts:

public class CountryContentProvider extends ContentProvider {

    public static final String PROVIDER = 
         "my.package.provider.countrycontentprovider";
    public static final Uri CONTENT_URI = 
         Uri.parse("content://" + PROVIDER + "/country");
    // ...
    @Override
    public boolean onCreate() { return true; }
    // ...
}


// from my activity
ContentResolver resolver = getContentResolver();
Cursor c = resolver.query(CountryContentProvider.CONTENT_URI, 
                                  null, null, null, null);  

// AndroidManifest.xml
<provider
    android:name="my.package.provider.CountryContentProvider"
    android:authorities="my.package.provider.countrycontentprovider" />

I have added the provider to the manifest and return true from the onCreate function. I use the CountryContentProvider.CONTENT_URI in my activity to get the Content from my provider, but I just keep getting that error message. I have removed and added the code three times (in case of eclipse melt down) to no avail.
I must be missing something. Can someone point me in the right direction?

Shastashastra answered 18/9, 2011 at 17:23 Comment(0)
V
50

I was able to reproduce your problem when I moved <provider> out of the <application>...</application> tag. Eclipse didn't say anything like error or warning.

Fortunately this issue is detected by Android Lint starting from ADT 20.

Vicennial answered 18/9, 2011 at 18:1 Comment(2)
So i means that <provider> tag should be placed inside <application> tag.Ento
Also, be careful not to put it inside an <activity> tag as I had done in the beginning.Douzepers
C
15

It worked for me only after specifying full path in Authorities tag in manifest file (see SearchableDictionary sample code in SDK).

<provider android:name=".DictionaryProvider"
       android:authorities="com.example.android.searchabledict.DictionaryProvider">
Compliance answered 6/12, 2012 at 21:28 Comment(0)
W
3

Inside your B-app which has the contentresolver, add this in the AndroidManifest.xml, outside application-tag

<queries>
        <provider android:authorities="com.authoritiesname.in.contentprovider.app" />
    </queries>
Weatherspoon answered 23/11, 2021 at 13:48 Comment(1)
Life saver!!. This should be added with respect to the package visibility changes from API Level 30 in AndroidSemiskilled
B
1

Setting the exported attribute to true in the provider tag in the manifest worked for me :

android:exported="true"

According to the documentation(http://developer.android.com/guide/topics/manifest/provider-element.html#exported), export is required only if the provider is to be available for other applications. But this is the only solution that worked for me.

Benelux answered 1/6, 2014 at 7:49 Comment(0)
S
0

The android:authorities= in the XML file is the content authority that is located in the contract class that you probably built. The content authority is added to the scheme to make the base content URI. Plain English, the reverse domain you used to make your app no caps here com.domain.sub.appName.

The android:name is the folder plus class your provider is named, do not forget the dot .folder.ProviderClassContentAuthorityIsIn.

Hope this helps :)

Sonorous answered 22/1, 2017 at 19:44 Comment(0)
P
-1

you have a capital letter and on the other line, one lowercase letter.

android:name= "my.package.provider.-C-ountryContentProvider" android:authorities="my.package.provider.-c-ountrycontentprovider"

it must be the same everywhere.

public static final String PROVIDER = 
     "my.package.provider.countrycontentprovider";
Perchance answered 18/8, 2014 at 2:16 Comment(1)
The authorities needs to match (i.e., same in the manifest as in the class file - my.package.provider.countrycontentprovider). And the class names need to match - my.package.provider.CountryContentProvider. So I don't think this is the issue.Beason
D
-2

Register your provider in the Android Manifest

<provider
    android:authorities="your_content_authority"
    android:name="yourProviderClass"/>
Donatus answered 22/9, 2016 at 1:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.