Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 5.1 adds android permission READ_PHONE_STATE automatically, how to remove it?

Discussion in 'Android' started by mark71, Jun 14, 2015.

  1. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    Interestingly "android.permission.READ_PHONE_STATE" is only added when I'm using "Build" or "Build & Run", but it is not added when I export the project to build manually.
    Does anyone know how I can prevent Unity to add this READ_PHONE_STATE permission (removing from a template would also work for me as a workaround).
     
  2. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Unity is not adding this permission by itself. Please check your plugins' manifests for missing targetSdkVersion attributes.
     
    pahe likes this.
  3. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    Yes, I added the targetSdkVersion to all manifest files (even those in .aar files! Took a while to find that out) and now it works fine.
     
    Yury-Habets likes this.
  4. kosted

    kosted

    Joined:
    Mar 14, 2015
    Posts:
    104
    skrpeta and Yury-Habets like this.
  5. etig

    etig

    Joined:
    Feb 15, 2015
    Posts:
    11
    how to change the manifest of war files?
     
  6. skrpeta

    skrpeta

    Joined:
    Nov 9, 2016
    Posts:
    18
    Maksim_Narchuk likes this.
  7. howler123

    howler123

    Joined:
    May 7, 2017
    Posts:
    17
    Just find the Android Manifest line that has it and remove it. I did and worked great.
     
    Yury-Habets likes this.
  8. azix

    azix

    Joined:
    Mar 15, 2013
    Posts:
    7
    Hi,

    I ran into the same permission problem when using Google Play Services with Unity 2017.3.1

    With an empty project and only PlayServicesResolver and a dependency to "com.google.android.gms:play-services-basement:12.0.0", the build asks for the phone state and external storage permissions.
    The Play Service library triggers theses permissions to be added to the manifest because including only the android app support libs ("com.android.support:support-v4:26.1.0") does not add these permissions.

    I resolved the problem by removing the permissions from the manifest using the tools:node="remove" attribute :


    <manifest ... xmlns:tools="http://schemas.android.com/tools">
    ...
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE" tools:node="remove"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove"/>
    ...
    </manifest>
     
  9. adam_mehman

    adam_mehman

    Joined:
    Dec 11, 2014
    Posts:
    104
    It is not working for me, what can I check more?
     
  10. azix

    azix

    Joined:
    Mar 15, 2013
    Posts:
    7
  11. adam_mehman

    adam_mehman

    Joined:
    Dec 11, 2014
    Posts:
    104
    I checked, permissions keep getting added even tho i set tools remove
     
  12. Kastar-Troy

    Kastar-Troy

    Joined:
    Jul 18, 2012
    Posts:
    29
    So this is a really crappy change in the manifest merger, cause it seems to be responding to files which have nothing to do with the manifest.

    I made a blank project and copied across my plugins folder to reproduce, and it did. I then went to remove anything which could cause be affected, and it turns out it wasnt any of the actual plugins, it was /plugins/Android/res/, which was simply a collection of xml files containing localised strings, and png files.

    what the actual F is this manifest merger doing?

    Anyway, easy way to find out what is putting Read State into your config, is trial and error with a copied version of your project, keep deleting stuff in plugins till read state disappears. Bit of Scientific method always does the trick.
     
  13. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    The issue of permissions popping up when Assets/Plugins/Android/res is present has been fixed some time ago.
     
  14. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    47
    UnityChannel.aar has that permission! Why is it there?