我正在使用Android SDK中的NotesList示例程序进行试验。我在程序中做了轻微的更改,但是当我安装我的编辑版本时,当我尝试在设备上已经安装原始notes程序时,我在控制台中一直得到消息INSTALL_FAILED_CONFLICTING_PROVIDER。我需要在提供者中更改什么以使其成为唯一的数据库?如果我卸载原来的notes程序,然后安装我编辑过的版本,它就可以正常工作。
当前回答
重命名包后可能会出现相同的错误。从AndroidManifest.xml中检查android:权威的string.xml中的值。
<provider
android:authorities="@string/content_authority"
android:name=".data.Provider"
... />
在string.xml中,该值应该与manifest中声明的包名相同。
<string name="content_authority">com.whatever.android.sunshine.app</string>
其他回答
检查<provider标签下的android:authorities属性
检查您的包名称是否正确
如果您在库项目中使用谷歌Maps +谷歌Play Services(特别是如果您最近从Eclipse迁移到Android Studio),当您尝试运行使用您的库的应用程序时,您可能会遇到此错误,而使用相同库的不同应用程序已经安装在您的设备上。
解决办法: 确保defaultConfig。applicationId是在构建的android部分定义的。Gradle文件为每个项目使用您的库
android {
defaultConfig.applicationId = "com.company.appname"
}
我建议使用特定应用程序的包名。有了这个修复,提供者名称将不再冲突,应用程序将按预期运行。
症状
1)。当用户从Play Store安装应用程序时,他们会看到可怕的“-505”安装错误。
2)。当你试图通过Android Studio [INSTALL_FAILED_CONFLICTING_PROVIDER]安装第二个使用你的库的应用程序时,你会看到这个错误消息:
在你的控制台中,你会看到这样一条消息:
Package couldn't be installed in /data/app/com.company.appname-1
com.android.server.pm.PackageManagerException:
Can't install because provider name
com.google.android.gms.measurement.google_measurement_service
(in package com.company.appname) is already used by
com.company.otherInstalledAppName
修复方法是确保defaultConfig. conf。applicationId是在构建的android部分定义的。Gradle文件为每个项目使用您的库
android {
defaultConfig.applicationId = "com.company.appname"
}
更多的阅读可以在原始错误报告中找到:问题784:多个应用程序使用相同的授权提供者名称
如果您正在使用提供者检查,并按照以下方法进行检查
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="androidx.multidex.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_path" />
</provider>
或者使用它
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.contentprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_path" />
</provider>
此外,如果应用程序已经退出在您的移动卸载,然后检查
need to use android:name="androidx.core.content.contentprovider
or android:name="androidx.core.content.provider insteadof
android:name="androidx.core.content.fileprovider
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.contentprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>
重命名包后可能会出现相同的错误。从AndroidManifest.xml中检查android:权威的string.xml中的值。
<provider
android:authorities="@string/content_authority"
android:name=".data.Provider"
... />
在string.xml中,该值应该与manifest中声明的包名相同。
<string name="content_authority">com.whatever.android.sunshine.app</string>
推荐文章
- 警告:API ' variable . getjavacompile()'已过时,已被' variable . getjavacompileprovider()'取代
- 安装APK时出现错误
- 碎片中的onCreateOptionsMenu
- TextView粗体通过XML文件?
- 如何使线性布局的孩子之间的空间?
- DSL元素android.dataBinding。enabled'已过时,已被'android.buildFeatures.dataBinding'取代
- ConstraintLayout:以编程方式更改约束
- PANIC: AVD系统路径损坏。检查ANDROID_SDK_ROOT值
- 如何生成字符串类型的buildConfigField
- Recyclerview不调用onCreateViewHolder
- Android API 21工具栏填充
- Android L中不支持操作栏导航模式
- 如何在TextView中添加一个子弹符号?
- PreferenceManager getDefaultSharedPreferences在Android Q中已弃用
- 在Android Studio中创建aar文件