Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use same ContentProvider authority in free and paid versions of app?

I've started using Android Library Projects to consolidate my paid and free version code.

I have run into a problem though with my ContentProvider. Since the ContentProvider is defined in the library class, both apps use the same authority. This means that android prevents the second app (in either order) from being installed due to an INSTALL_FAILED_CONFLICTING_PROVIDER error.

05-22 11:14:40.563: WARN/PackageManager(102): Can't install because provider name com.cfms.android.podcast (in package com.cfms.android.podcastlite) is already used by com.cfms.android.podcastpaid
05-22 11:14:40.563: WARN/PackageManager(102): Package couldn't be installed in /data/app/com.cfms.android.podcastlite-2.apk

How can I deal with this issue? Ideally I'd like the authorities to be the same for each app version, so I don't have to put in a bunch of exceptions in the common code library. If that is not possible, how should I go forward?

like image 944
CodeFusionMobile Avatar asked May 22 '11 16:05

CodeFusionMobile


1 Answers

It's simply not possible to have two apps on the same device with different providers using the same authority.

http://hustleplay.wordpress.com/2010/02/28/android-install_failed_conflicting_provider/

android duplicate provider authority.

I would create a different string resource in each application, that is then passed to the library to create the provider with the appropriate authority.

like image 91
CL22 Avatar answered Sep 19 '22 13:09

CL22