Post

How to Fix Unity Android Permission Not Being Removed Issue

How to Fix Unity Android Permission Not Being Removed Issue
Visitors
  • An issue occurred where Unity Android Permission was not being removed.
  • The READ_EXTERNAL_STORAGE permission, which is not even used, kept being included in the build.

    Desktop View


Root Cause Analysis

  • First, I checked the AndroidManifest file, but there was no usage of that permission.
  • I searched the entire project to see where it was being used…

    Desktop View

    Desktop View

  • I found a Unity package cache file called PostprocessorTests, an internal class of Unity.Notifications.Tests.
  • It turned out this class inside the Mobile Notification package was using that permission.

    Desktop View


Solution

  1. Check if the permission you want to remove exists in the AndroidManifest file. In my case, it was READ_EXTERNAL_STORAGE.
  2. Use the “Find in Files” feature in your IDE (Rider or Visual Studio) to search for the permission string and verify if it’s being used anywhere.
  • Permission Example:
    1
    2
    3
    4
    5
    
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" android:minSdkVersion="33" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" android:minSdkVersion="33" />
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" android:minSdkVersion="33" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
    
  1. If there is a permission you want to remove, delete it boldly.
  2. However, since it might be included in Unity packages or plugins, you must handle it explicitly.
  • You can resolve this by explicitly specifying remove.
    1
    
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove" />
    
  • Result: Desktop View
This post is licensed under CC BY 4.0 by the author.