Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

READ_PHONE_STATE permission added when using SDK tools 26.0.2

Discussion in 'Android' started by pep_dj, Jul 4, 2017.

  1. pep_dj

    pep_dj

    Joined:
    Nov 7, 2014
    Posts:
    174
    I've updated Android SDK tools to 26.0.2, and now game builds ask for READ_PHONE_STATE permission (and READ_EXTERNAL_STORAGE also). Switching back to 25.2.3 solves the problem. But, I would like to use latest SDK tools.

    This issue is also listed in Unity Issue Tracker: https://issuetracker.unity3d.com/is...fest-dot-xml-file-using-latest-26-dot-0-2-sdk

    Do you know how can we fix it?

    EDIT: The issue has been solved after I added
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" /> to everyplay manifest.xml file
     
    Last edited: Jul 5, 2017
    Yury-Habets, tomerpeledNG and vrfurl like this.
  2. vrfurl

    vrfurl

    Joined:
    Feb 10, 2017
    Posts:
    1
    this worked for me. Thanks for sharing
     
  3. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    Worked for me as well.
    Thanks
     
  4. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,161
    Plugins with manifests where targetSdkVersion is missing will cause this undesired behavior. The correct fix is to add this entry to the manifest - @pep_dj is correct.
     
    rsodre likes this.
  5. Don_K

    Don_K

    Joined:
    May 31, 2016
    Posts:
    8
    I fix my project,
    For all AndroidManifest.xml in the Asset folder
    <uses-sdk android: minSdkVersion = "16" android: targetSdkVersion = "25" />
    I added it and built it with UnityCloudBuild.

    But, the READ_PHONE_STATE permission remained.

    Can you give me some advice?
     
  6. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,594
    @Yury-Habets : What if multiple manifest files specify different SDK Targets?
    Isn't it dependent on main root manifest file? Please suggest.

    Thanks,
    Ayyappa
     
  7. pfleetwood22

    pfleetwood22

    Joined:
    Jun 6, 2016
    Posts:
    28
    @Yury-Habets I have been unable to resolve the unwanted addition of READ_PHONE_STATE in Cloud Builds. I cannot reproduce the introduction of that permission locally. I have ensured that I have buildToolsVersion of 26.0.1 in my locally exported build.gradle file. So, my first concern is that Cloud Build is doing something differently than I am locally. I'm using 5.3.6p1 both locally and on Cloud Build.

    I've also made sure that every AndroidManifest has specified a minSdkVersion in the uses-sdk block of at least 9. My understanding from the documentation (https://developer.android.com/reference/android/Manifest.permission.html#READ_PHONE_STATE) (though it is slightly ambiguous) is that if minSdkVersion is specified greater than 3, the READ_PHONE_STATE will not be implicitly added. I have introduced targetSdkVersion when it was missing in my loose AndroidManifest files, but many of the google AARs contain AndroidManifest files inside them that only specify a minSdkVersion.

    Can you help me to determine why Cloud Build is introducing this permission?
     
  8. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,161
    If the google AARs are missing targetSdkVersion - that's bad. Can you please tell me which ones?
    In that case, it has probably nothing to do with the cloud build. Pinging @dannyd in case this is something known.
     
  9. pfleetwood22

    pfleetwood22

    Joined:
    Jun 6, 2016
    Posts:
    28
    Just to reiterate, my local gradle builds do not introduce the READ_PHONE_STATE permission, but the Cloud Builds do.

    All these AARs in my project have a minSdkVersion but not a targetSdkVersion:

     
  10. pfleetwood22

    pfleetwood22

    Joined:
    Jun 6, 2016
    Posts:
    28
  11. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,161
    This issue was fixed in all Unity versions starting 17.1 (in one of the patch releases), 5.6 patch release pending.
     
  12. pfleetwood22

    pfleetwood22

    Joined:
    Jun 6, 2016
    Posts:
    28
    @Yury-Habets Any word on the 5.6 patch release with this fix?
    Thanks
     
  13. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,161
    5.6.4p1 should be the one.
     
    mayucy likes this.
  14. hutch_jl

    hutch_jl

    Joined:
    Jan 8, 2013
    Posts:
    40
    Hi @Yury-Habets , I've just seen that 5.6.4p1 has been released but there doesn't seem to be an obvious entry in the changelog referencing this bug, do you know if it made it in?
     
  15. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,161
    Yes it should be there - looks like I missed to add the release note entry.
     
  16. hutch_jl

    hutch_jl

    Joined:
    Jan 8, 2013
    Posts:
    40
    Great thanks, will give it a go.
     
  17. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    288
    This is still happening in 2017.1.2p2

    Adding

    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />

    To each manifest in my project fixed it.
     
    Dazo1985 likes this.
  18. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,161
    @Aurigan please read carefully - the fix I've been talking of is about having Assets/Plugins/Android/res folder present. In this case, we generate an Android library, and it was missing targetSdkVersion in the manifest. I fixed that.

    However, if you have any plugins (libraries) added with NO targetSdkVersion in the manifest - you automatically get the dangerous permission in question. The only fix for this issue is to fix your plugins' manifests.
     
  19. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    288
    @Yury-Habets Hi, the issue for me came from including the IronSource Ad SDK. While I *could* fix this by adding a target SDK version myself after some wasted minutes or hours of my day I view this as something that Unity *could* do for me ... especially given that there's a minimum and target API already set in Player Settings ...
     
  20. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,161
    @Aurigan no - this is what the plugin author must do - claim the minimum and target SDK levels he is expecting his plugin to work with. We can't decide it for him.
     
  21. jknight-nc

    jknight-nc

    Joined:
    Jun 10, 2014
    Posts:
    52
    Why can't unity prevent the addition of READ_PHONE_STATE when the targetSdk is missing?
     
  22. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    821
    Because we collect manifests (if building with internal build system) or gradle does that and pass them to a manifest merger tool (which comes with android sdk). The tool does this while merging manifests.
     
  23. adam_mehman

    adam_mehman

    Joined:
    Dec 11, 2014
    Posts:
    104
    i have only 2 manifests, both of them are having minsdk but unity still creates PHONE_STATE permission.

    I even tried to add <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />

    I even tried to add tools:node="remove" and problem still persists

    What can I check more?

    I have a Unity 5.6.4f1
    I have few res folders
    I use Facebooks SDK and Unity Analytics.

    Should I install Unity 5.6.4p4 and try or?
     
    Last edited: Mar 28, 2018
  24. adam_mehman

    adam_mehman

    Joined:
    Dec 11, 2014
    Posts:
    104
    So I found it,

    Unity IAP plugin has READ_PHONE_STATE permission and Unity Channel (within their aar files).

    I will try to remove it now.
     
  25. adam_mehman

    adam_mehman

    Joined:
    Dec 11, 2014
    Posts:
    104
    Nope, didn't help.

    I lost all the ideas :/