Xamarin Android (App Rejected on Playstore - Issue: Need to use Media Store API or No Access to Files)

Gilberto Matos 21 Reputation points
2022-01-03T20:17:05.327+00:00

Hi!

I am facing an issue that I believe many xamarin android developers may also be facing. My app, up to android version 10 worked correctly. Basically I need to create at runtime (and update too), a SQLite .db file and two json files. Within the app, the user has the possibility to take a photo and save it or select a photo and save it too. All these files I'm saving in the app folder, fetching the url like this:

   Path.Combine(FileSystem.AppDataDirectory, "filename").  

Now with android 11 scoped storage I am getting the error "App Rejected on Playstore - Issue: Need to use Media Store API or No Access to Files". I've done a lot of research, read several articles, tried to find something in xamarin android c# about the same problem, but nothing makes the app to be accepted in the playstore. In my understanding, the app folder does not ask for permissions to write files. As a test, I migrated my app from xam.plugin.media plugin to xamarin.essentials.mediapicker. Removed all access permissions to internal and external storage from android.manifest (READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE and MANAGE_EXTERNAL_STORAGE) and it still didn't work. The creation of files, I'm doing as follows:

I noticed that xamarin.essentials.mediapicker asks for permission to access internal storage for capturing photos and selecting saved images. Friends, I ask for your help, as I am already confused where I should attack and how to solve this problem. I don't know if the problem is related to the selection or image capture or if it is in the recording of .db and json files. I tried to implement in my code, to take, for example, the sqlite .db file, without creating it at runtime, but I wasn't successful either, because I can't access it in the assets or ressources folder to open the connection. The biggest problem is understanding exactly what google is complaining about and how to use the Media Store API that it orders to be used with xamarin android. Any help will be welcome.

NOTE: I cannot use xamarin.essentials.mediapicker? I can't save files in the app folder (files) ? How to solve?
@Alessandro Caliaro @James Montemagno any idea friends?

Thanks!

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,690 questions
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 68,416 Reputation points Microsoft Vendor
    2022-01-04T03:11:58.17+00:00

    Hello,​

    Welcome to our Microsoft Q&A platform!

    First of all, MANAGE_EXTERNAL_STORAGE will be rejected on Playstore if you application is not include the following type application.

       File managers  
       Backup and restore apps  
       Anti-virus apps  
       Document management apps  
       On-device file search  
       Disk and file encryption  
       Device-to-device data migration  
    

    If you remove the Permission, you need to update the build number on Internal Track. you have to update the build on every track(Open testing, Closed testing, Production, etc.) even if permission are disabled in android 11. Here is similar thread1 and thread 2

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful