内容提供商 INSTALL_FAILED_CONFLICTING_PROVIDER(将内容提供商作为单独的 apk 安装)
我有两个使用相同内容提供程序的应用程序,但我无法在两个应用程序中放置相同的内容提供程序 - 它显示 INSTALL_FAILED_CONFLICTING_PROVIDER 错误。因此,我将我的内容提供程序放在第三个 .apk 中,并从两个应用程序中使用它,并且运行良好。
现在的问题是 - 必须先安装内容提供商 apk,然后才能在设备上安装这两个应用程序中的任何一个。否则,在安装过程中会显示 Provider not found 错误。
那么,如何确保在安装任何其他 apk 之前安装提供程序 apk?
有没有办法将内容提供程序 apk 与其他两个 apk 分别合并,这样它们将作为两个应用程序安装在一起,并且不会显示 INSTALL_FAILED_CONFLICTING_PROVIDER 错误?
我需要将内容提供商 apk 与两个应用程序合并,因为用户可能不会安装这两个应用程序,或者可能会将它们安装在单个设备上。
I have two applications which use the same content provider, but I can't put the same content provider in both applications- it shows INSTALL_FAILED_CONFLICTING_PROVIDER error. So I have put my content provider in a 3rd .apk and used this from two applications and it is working well.
Now the problem is- The content provider apk must be installed before any of those two apps can be installed on the device. Otherwise, it shows Provider not found error during installation.
So, how can I ensure that the provider apk is installed before any of the other apks is installed?
Is there a way to merge the content provider apk with both of the other apks separately, so they will be installed together as two applications and won't show INSTALL_FAILED_CONFLICTING_PROVIDER error?
I need to merge the content provider apk with both applications, because the user may not install both applications or may install them both on a single device.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以通过更改
AndroidManifest.xml
文件中android:authorities
的值来解决该问题。错误的原因是您设备上安装的另一个应用程序已经对android:authorities
使用了相同的值。You can solve it by changing the value of
android:authorities
in yourAndroidManifest.xml
file. The reason for the error is that another application installed on your device already uses that same value forandroid:authorities
.我能想到的一种解决方案是,使内容提供程序成为内部具有不同 packageid 的应用程序的一部分。并使用 android:exported = true 导出它。不过,两者可能使用相同的代码。
在应用程序启动时,您检查设备上是否存在其他内容提供商,如果存在则开始使用它,否则您将回退到本地内容提供商。当其他应用程序安装时,它可以执行相同的检查。
为了保护您的内容提供者免受其他人的侵害,您可以定义自定义权限来保护它,以便您的应用程序只能使用它,或者您也可以设置一些自定义身份验证(例如某些密钥)来访问内容提供者。您可以在内容提供商的所有方法中拥有此身份验证代码。
One solution i can think of is, make content provider part of both the applications with different packageid's internally.and export it using android:exported = true. Both might be using the same code though.
At the start of the application you check if the other content provider exists on the device if it's there you start using it,otherwise you fallback to local content provider. when the other applicaton installs it can does the same check.
To protect your cotent provider from everyone else, you can define a custom permission to protect it, so that your applications can only use it or you can also put some custom authentication like some secret key to access the content provider. you can have this authentication code in all methods of content provider.
要解决此错误:
安装错误:INSTALL_FAILED_CONFLICTING_PROVIDER
更改 AndroidManifest 中
android:authorities
的值.xml 文件中安装在您设备上的另一个应用程序已对 android:authorities 使用相同的值。To solve this error:
Installation error: INSTALL_FAILED_CONFLICTING_PROVIDER
change the value of
android:authorities
in your AndroidManifest.xml file another application installed on your device already uses that same value for android:authorities.您可以在清单文件 (AndroidManifest.xml) 中为这两个程序使用一个 unic 数据,例如 Facebook API 注册号或类似的数据:已安装的程序和您尝试安装但无法安装的程序。您需要:
程序:
您尝试安装的程序。
You use one unic data like Facebook API registration numer or something like it in your manifest file (AndroidManifest.xml) for both programs: for which already installed and for that you try and cant install. You need:
program:
program you trying to install.
这意味着您的手机已经拥有具有相同权限的提供商,由不同的应用程序注册(可能是您的其他示例)。更改您的提供商权限,即
android:authorities
,您就可以开始了。It means your phone already has provider with same authorities, registered by different application(could be your other example).Change your provider authorities i.e.
android:authorities
and your are good to go.