xamarin / XamarinComponents

Plugins for Xamarin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Xamarin.Google.Android.Vending.Expansion.Downloader: PendingIntent Flags on Android 31

davideravasi opened this issue · comments

Hello everyone,
I have an issue with the library Xamarin.Google.Android.Vending.Expansion.Downloader (last version: 2.1.0) if I target android 31 in my manifest.

The issue I got from the device logs is the following one:

Error (5111) / AndroidRuntime: FATAL EXCEPTION: IntentService[LVLDownloadService]
Error (5111) / AndroidRuntime: Process: com.swisssign.swissid.mobile, PID: 5111
Error (5111) / AndroidRuntime: java.lang.IllegalArgumentException: com.swisssign.swissid.mobile: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Error (5111) / AndroidRuntime: Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
Error (5111) / AndroidRuntime: at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
Error (5111) / AndroidRuntime: at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
Error (5111) / AndroidRuntime: at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
Error (5111) / AndroidRuntime: at com.google.android.vending.expansion.downloader.impl.DownloaderService.scheduleAlarm(DownloaderService.java:958)
Error (5111) / AndroidRuntime: at com.google.android.vending.expansion.downloader.impl.DownloaderService.onHandleIntent(DownloaderService.java:1077)
Error (5111) / AndroidRuntime: at com.google.android.vending.expansion.downloader.impl.CustomIntentService$ServiceHandler.handleMessage(CustomIntentService.java:104)
Error (5111) / AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
Error (5111) / AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
Error (5111) / AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
Error (5111) / AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:67)
Debug (5111) / LVLDL: InnerBroadcastReceiver Called

The error happens in the following lines of code:
Screenshot 2022-12-08 at 15 36 17

When I try to download expansion files from the Play Store basically.

Now, I checked and the Pending Intent I pass in the method DownloaderService.StartDownloadServiceIfRequired has the right flag (IMMUTABLE).

Then, after more research I found this piece of code from @mattleibow (sorry for mentioning you, but I don't find any reference for this online)
Screenshot 2022-12-08 at 15 30 51

And, ta-da, in the class > https://github.com/mattleibow/Android.Play.ExpansionLibrary/blob/master/ExpansionDownloader/Service/DownloaderService.cs

Seems like the pending intent DOES NOT have the required flag.

Now I don't know if we are talking about the same class, I see that the package (Xamarin.Google.Android.Vending.Expansion.Downloader) was updated last time 2 years ago.

Any fix for this? It's pretty urgent since Play store forces android 31 as target now and our app need expansion files to work!

Thx in advance

@davideravasi if you are shipping 'assets' you might want to consider moving over to Asset Packs. Asset packs are compatible with aab files which the old expansion files are not atm.

I put a Xamarin sample together at https://github.com/infinitespace-studios/XamarinLegacyDynamicAssetsExample.