4

Android Manifest sharedUserId attribute is now deprecated:

This constant was deprecated in API level 29. Shared user IDs cause non-deterministic behavior within the package manager. As such, its use is strongly discouraged and may be removed in a future version of Android. Instead, apps should use proper communication mechanisms, such as services and content providers, to facilitate interoperability between shared components.

I have "Free" and "Pro" app versions sharing user ID, because I wanted to easily copy data from Free to Pro if users decided to upgrade. Also having sharedUserId prevents me from making my app an "Instant app" - when trying to test locally I'm getting this error:

Failure [-116: Instant app package may not declare a sharedUserId]

So I'm thinking about migrating from sharedUserId, but I don't see how, even if I put the data copy situation aside for now. If I clear sharedUserId for the next version of my app, then updated app version is not going to be able to read the data from the previous version, as indicated in this Stackoverflow question

This looks like a dead end. I basically need to be able to still access SQLite database, but I think it is also tied to sharedUserId.

smok
  • 1,658
  • 13
  • 13
  • 1
    "I basically need to be able to still access SQLite database, but I think it is also tied to sharedUserId" -- for this, and your "data copy situation", the idea is that you would have one app expose an API for the other app to use. For example, SQLite might be covered by a `ContentProvider`. They will not be able to remove `sharedUserId` for existing installs for the reason you cited, but they might make it have no effect for new installs. So, I would focus less on removing `sharedUserId` and more on ensuring that your app can work even if it has no effect. – CommonsWare Jul 12 '20 at 14:02
  • Making `sharedUserId` have no effect for new installs makes sense, so I need to stop relying on it anyway. But the inability to migrate safely makes me stuck with it until the vast majority of devices are on the OS version that ignores `sharedUserId`. PS and while I'm stuck with `sharedUserId` I can't make my app "instant". – smok Jul 23 '20 at 20:58
  • @smok not sure why you say it's an "inability to migrate safely". Why can't you just use `ContentProvider` as @CommonsWare said? – Adam Burley Dec 08 '21 at 17:19
  • Hi @CommonsWare and team.. any idea how to keep maintain this shareduid in android 11 and use of android:sharedUserMaxSdkVersion="32" will not impact the certification – Subhalaxmi Jul 13 '22 at 14:27

0 Answers0