[英]Remove WRITE_EXTERNAL_STORAGE and READ_EXTERNAL_STORAGE permissions from Android Project
I removed the WRITE_EXTERNAL_STORAGE
and READ_EXTERNAL_STORAGE
permissions from the project's AndroidMainfest.xml
and AssemblyInfo.cs
files.我从项目的
AndroidMainfest.xml
和AssemblyInfo.cs
文件中删除了WRITE_EXTERNAL_STORAGE
和READ_EXTERNAL_STORAGE
权限。
I uploaded the.apk to Play Store and in the Bundle permissions the Write & Read permissions were showing up.我将.apk 上传到 Play 商店,并且在 Bundle 权限中显示了写入和读取权限。
Then I analyzed the .apk
using Analyze APK
feature in Android Studio, and in that, AndroidMainfest.xml
has WRITE_EXTERNAL_STORAGE
and READ_EXTERNAL_STORAGE
.然后我使用 Android Studio 中的
Analyze APK
功能分析了.apk
,其中AndroidMainfest.xml
具有WRITE_EXTERNAL_STORAGE
和READ_EXTERNAL_STORAGE
。
Though, I ask for CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage)
on run time, but when I removed it and Analyzed the APK, still it includes WRITE_EXTERNAL_STORAGE
and READ_EXTERNAL_STORAGE
permissions in Manifest file.虽然,我在运行时要求
CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage)
,但是当我删除它并分析 APK 时,它仍然在 Manifest 文件中包含WRITE_EXTERNAL_STORAGE
和READ_EXTERNAL_STORAGE
权限。
I then add the android:requiredFeature="false"
flag to Write & Read permissions like this:然后我将
android:requiredFeature="false"
标志添加到写入和读取权限,如下所示:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:requiredFeature="false" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:requiredFeature="false" />
And when I Analyzed the APK again, Write & Read permissions are there with android:requiredFeature="false"
.当我再次分析 APK 时,写入和读取权限存在
android:requiredFeature="false"
。 But on Play Store, in the Bundle permissions they are there as before.但是在 Play 商店中,在 Bundle 权限中它们和以前一样。
I don't know why these permissions are ending up there?我不知道为什么这些权限会在那里结束?
@Sergey Comment: They can be merged from the dependent library. @Sergey 评论:它们可以从依赖库中合并。 You can check if any library you are using have those permissions in their Manifest file.
您可以检查您正在使用的任何库是否在其清单文件中具有这些权限。
I looked into it and found this article How Libraries can silently add permissions to your Android App and the Fix .我调查了一下,发现这篇文章库如何默默地为您的 Android 应用程序和修复添加权限。 It Worked .
它奏效了。
But I'm using camera, and I was storing these pictures in the Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
.但是我使用的是相机,并且我将这些图片存储在
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
中。 Which requires WRITE_EXTERNAL_STORAGE
and READ_EXTERNAL_STORAGE
permissions.这需要
WRITE_EXTERNAL_STORAGE
和READ_EXTERNAL_STORAGE
权限。
So, I replace the path with FileSystem.CacheDirectory
and it worked (Intenral Storage doesn't requires Read and Write Permissions in Manifest file).因此,我将路径替换为
FileSystem.CacheDirectory
并且它有效(内部存储不需要清单文件中的读写权限)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.