android:内容提供商:服务在凝视时崩溃 - 无法获取提供商sensordata.collector.SurveyDbProvider
我已经建立了自己的内容提供商。许多应用程序必须共享该数据库。
但是当我启动服务时它崩溃了。我什至在日志中没有发现任何异常。
看起来像是清单问题,因为在我添加与提供商相关的标签后问题就开始了。
Package:sensordata.collector
Clas name : SurveyDbProvider [SurveyDbProvider extends ContentProvider]
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sensordata.collector"
android:versionCode="1"
android:versionName="1.0">
<permission
android:name="sensordata.collector.SURVEY_DATA.permission.READ"
android:label="@string/perm_label"
android:description="@string/perm_label" />
<permission
android:name="sensordata.collector.SURVEY_DATA.permission.WRITE"
android:label="@string/perm_label"
android:description="@string/perm_label" />
<uses-permission android:name="sensordata.collector.SURVEY_DATA.permission.WRITE" />
<uses-permission android:name="sensordata.collector.SURVEY_DATA.permission.READ" />
In application tag :
<provider android:name="sensordata.collector.SurveyDbProvider"
android:authorities="sensordata.collector"
android:readPermission="sensordata.collector.SURVEY_DATA.permission.READ"
android:writePermission="sensordata.collector.SURVEY_DATA.permission.WRITE" />
</application>
<uses-sdk android:minSdkVersion="4" />
</manifest>
请帮忙。
I have built my own content provider. Many applications have to share this database.
But when I start my service it crashes. I didn't even get any exceptions in the log.
Looks like issue with manifest, since after I added tags realted to provider issue started.
Package:sensordata.collector
Clas name : SurveyDbProvider [SurveyDbProvider extends ContentProvider]
This is my manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="sensordata.collector"
android:versionCode="1"
android:versionName="1.0">
<permission
android:name="sensordata.collector.SURVEY_DATA.permission.READ"
android:label="@string/perm_label"
android:description="@string/perm_label" />
<permission
android:name="sensordata.collector.SURVEY_DATA.permission.WRITE"
android:label="@string/perm_label"
android:description="@string/perm_label" />
<uses-permission android:name="sensordata.collector.SURVEY_DATA.permission.WRITE" />
<uses-permission android:name="sensordata.collector.SURVEY_DATA.permission.READ" />
In application tag :
<provider android:name="sensordata.collector.SurveyDbProvider"
android:authorities="sensordata.collector"
android:readPermission="sensordata.collector.SURVEY_DATA.permission.READ"
android:writePermission="sensordata.collector.SURVEY_DATA.permission.WRITE" />
</application>
<uses-sdk android:minSdkVersion="4" />
</manifest>
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
授权机构缺少 ContentProvider 名称。它应该是:
作为一个好的实践,您应该在提供程序类中声明一个与此权限匹配的 CONTENT_URI 常量。
The authority is missing the ContentProvider name. It should be:
And as a good practice you should declare a CONTENT_URI constant matching this authority inside the provider class.
您的提供者有公共构造函数吗?
Sensordata.collector.SurveyDbProvider 必须是可初始化的,因此它不能是抽象类。
如果您没有看到异常并且您正在使用 Eclipse,请按 F8(可能多次)并检查您的 LogCat
Does your provider has a public constructor ?
The sensordata.collector.SurveyDbProvider has to be initializable, so it cannot be for example abstract class.
if you do not see exceptions and you are using Eclipse, press F8, maybe multiple times and check your LogCat