找不到' ContentProvider'的提供商信息 [英] Failed to find provider info for 'ContentProvider'
问题描述
我有一个我无法解决的问题.我正在使用Eclipse创建自己的内容提供程序,但始终收到以下错误:
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:
[..]错误/ActivityThread(1051):无法找到提供程序的信息my.package.provider.countrycontentprovider
[..] ERROR/ActivityThread(1051): Failed to find provider info for my.package.provider.countrycontentprovider
在此处找到代码: http://codepad.org/Rx00HjHd
主要部分:
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" />
我已将提供程序添加到清单中,并从 onCreate
函数返回true.我在活动中使用 CountryContentProvider.CONTENT_URI
从提供商处获取内容,但我一直在获取该错误消息.我已删除并添加了3次代码(以防日食融化),但无济于事.
我肯定错过了什么.有人可以指出我正确的方向吗?
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?
推荐答案
当我将< provider>从< application> ...</application>标记中移出时,我能够重现您的问题.Eclipse没有说任何错误或警告.
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.
幸运的是,从ADT 20开始,Android Lint可以检测到此问题.
Fortunately this issue is detected by Android Lint starting from ADT 20.
这篇关于找不到&#39; ContentProvider&#39;的提供商信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!