Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Content Provider INSTALL_FAILED_CONFLICTING_PROVIDER (installing content provider as a separate 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.

like image 865
Imon Avatar asked Jun 08 '11 02:06

Imon


4 Answers

You can solve it by changing the value of android:authorities in your AndroidManifest.xml file. The reason for the error is that another application installed on your device already uses that same value for android:authorities.

like image 195
Ali Ashraf Avatar answered Oct 04 '22 10:10

Ali Ashraf


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.

like image 44
Naresh Avatar answered Oct 04 '22 10:10

Naresh


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.

like image 21
Jorgesys Avatar answered Oct 04 '22 11:10

Jorgesys


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:

  1. Try to find something like this and check is it for your current program:

android:authorities="com.facebook.app.FacebookContentProvider23473465463573466" android:name="com.facebook.FacebookContentProvider" android:exported="true"/>

  1. Check if is not dublicate in another programs if it is for program you trying to install.
like image 34
Iefimenko Ievgen Avatar answered Oct 04 '22 11:10

Iefimenko Ievgen