Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

How to remove android.permission.READ_EXTERNAL_STORAGE ?

Discussion in 'Android' started by De-Panther, Sep 4, 2016.

  1. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    590
    As I understand, Unity detects code that needs this permission, and then add this permission to the AndroidManifest file.
    I can remove it by unpacking the apk with external tool, edit the AndroidManifest and repacking the apk.

    But I don't want to use an external tool.
    I want to know which part of the code ask for this permission, and if I can remove it(maybe it's in a dll of one of the plugins I use), I'll remove it.
    I would also want a way to remove it even if there is a code that use it, but I guess that this won't happen soon :/

    So, is there a documentation about which System/UnityEngine classes add some unwanted permissions?

    Thanks
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I am not sure this is is all that Unity does, but you should look into the GenerateManifest class (in UnityEditor.Android.Extensions.dll). Specifically, the SetPermissionAttributes method will added various permissions to the manifest.
    Again, i am not sure this is ALL that Unity does.. but worth checking out.

    I believe that all the tools you need are already available in the Android SDK, but that would be a hassle to do for every build i guess.
    Android plugins are sometimes packaged as .aar libraries (a .zip file that also contains an AndroidManifest). These can contain permission declarations as well (not only .DLLs like you mentioned).

    Why are you trying to do that? why do you care that this permission will be added to your .apk ?

    Maybe @Yury-Habets knows of some of these APIs.
     
  3. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Actually, I don't think we add READ_EXTERNAL_STORAGE ourselves. We do add WRITE_EXTERNAL_STORAGE based on the write access in the player settings, and if "Split application binary" is selected (the latter is no longer true for latest Unity versions - we left it for the OBB plugin to manage its permissions).

    @De-Panther please check your plugins. If you see Unity adding this permission on an empty project - please submit a bug report immediately!

    By the way, a part of my hack week project was to identify which plugin caused which permission. It may find its way to the Unity code some day...
     
  4. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    590
    Found the guilty ".aar" file.
    "OVRPlugin.aar" it's in the Unity installation folder - "Editor\Data\VR\Unity\Android"
    I'm building the game for the GearVR.
    As far as I know, it's not a required permission. So it's strange that it's there. I'm using Unity 5.4.0f3 (64-bit).
     
  5. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    590
  6. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    590
    And... apparently this permission is a must for the GearVR Store. So I wasted my time for nothing :p
     
  7. igorpavlov

    igorpavlov

    Joined:
    Dec 24, 2016
    Posts:
    2
    Last edited: Jan 31, 2017
    Yury-Habets likes this.
  8. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Hi @Yury-Habets
    Where i can find your project ? Thanks in advanced.
     
  9. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Unfortunately it's sitting in one of the development branches, and is not public at the moment. I may want to spend some time once to actually make it happen...
     
    De-Panther likes this.
  10. tessellation

    tessellation

    Joined:
    Aug 11, 2015
    Posts:
    394
    @Yury-Habets All we need is the manifest merger report as a log file. Otherwise, it's SO MUCH WORK to figure out which of the thousands of libraries we use are adding unwanted permissions. Is this possibly written out somewhere already?
     
  11. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
  12. Ictcmn

    Ictcmn

    Joined:
    Nov 17, 2014
    Posts:
    12
    Just a random thought on this as I just had to solve this issue to submit something to Meta Quest Store. In my instance I believe it was because I was splitting my binary for size reasons. When I turned off that option, it removed android.permission.READ_EXTERNAL_STORAGE from my manifest.

    So that's under Player Settings > Publishing Settings > Split Application Binary.