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?
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.
Could you try something like this?
http://ncsoftworks.com/forums/discussion/6/sharedpreferences-between-applications
Also isn't the authority of a content provider just a private embedded linux folder name? And isn't a content provider just a SQLite database file inside that private folder?
And can't we share the same folder between applications as long as we sign both applications with the same key and the same application package name thereby creating a shared user id?
In any case, I'm just thinking out loud at this point. I'll have to experiment with this. I'm just posting this up to save myself some time in case someone finds the flaw in my assumptions (before I have time to do the experiment).
Note: I said application package name, not activity package name. As I understand it, Android applications usually contain two package names (although the Eclipse New project wizard usually labels both packages with the same name, thereby creating the impression that there is only one package name)
精彩评论