Search Unity

Unity Android IAP keeps adding READ_PHONE_STATE permission, and I just can't remove it

Discussion in 'Android' started by ThalesQwerty, May 10, 2018.

  1. ThalesQwerty

    ThalesQwerty

    Joined:
    Feb 14, 2016
    Posts:
    7
    I'm almost finishing a simple arcade game I've been developing for Android, and I'm currently trying to add a "Remove Ads" feature, which you pay $0,99 to remove the advertisements that occasionaly appear after you lose the game. The ads were pretty easy to implement, but the Unity In App Purchase is really giving me headaches.

    The problem is that, no matter what I do, every damn time I import the Unity IAP to the project and build the APK file, the READ_PHONE_STATE permission will be added in there. I don't want this permission in there because, firstly, it's unneccessary for the purchases to work, and secondly, it may make users distrust my game: "If it's just a simple game, why is it asking for allowance to make and manage phone calls??" — And I wouldn't blame them, it's a very reasonable suspicion.

    I've been googling around this issue during the entire day and I tried all the solutions I found in the Forums and Answers pages (changing AndroidManifest.xml files, changing target/minimum SDKs, downloading different versions of Unity IAP plugin, etc.), but unfortunately I had no success. So I'm opening a new thread here in order to see if I can get some new information that may help me out. The only way I found to remove it is to delete the entire IAP plugin for my project and then build the APK, but that's obviously not a valid solution and misses my initial purposes entirely.

    How can I remove READ_PHONE_STATE permission from my game? Why isn't there a feature that allows me to manage permissions?
     
    ssvjatoy likes this.
  2. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,875
  3. ThalesQwerty

    ThalesQwerty

    Joined:
    Feb 14, 2016
    Posts:
    7
  4. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,875
    Which Unity version are you using?
     
  5. ThalesQwerty

    ThalesQwerty

    Joined:
    Feb 14, 2016
    Posts:
    7
    5.3.1f1
     
  6. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,875
    Then Gradle should be the "Google Android Project" tick, AFAIK.
     
  7. ThalesQwerty

    ThalesQwerty

    Joined:
    Feb 14, 2016
    Posts:
    7
    Yeah, I already tried using that and it does create the project. But I'm unable to build an APK with Android Studio or even directly with Gradle on the command prompt.

    The furthest I reached was creating a JAR file that dosen't even run in my computer.
     
  8. yasirkula

    yasirkula

    Joined:
    Aug 1, 2011
    Posts:
    2,875
    Hmm, if upgrading your project to at least Unity 5.6 is not an option (for Gradle Build System), then I'm out of ideas. I hope someone can point you in the right direction.
     
  9. marcinlazo

    marcinlazo

    Joined:
    Mar 21, 2018
    Posts:
    3
    Did you manage to remove the permission? I'm facing the same issue.
     
  10. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    READ_PHONE_STATE permission may pop up unexpectedly if one of your plugins is missing targetSdkVersion in its manifest. Try searching your plugins' manifests and fix it. (Unity IAP should work correctly).

    More detailed description:
    https://issuetracker.unity3d.com/is...fest-dot-xml-file-using-latest-26-dot-0-2-sdk

     
  11. Nunterfal

    Nunterfal

    Joined:
    Nov 3, 2011
    Posts:
    9
    @Yury-Habets got the same issue after upgrading from IAP version 1.12 to 1.17. Nothing else was changed. Move back to previous commit with IAP 1.12 - everything is fine, but after upgrade to 1.17 got READ_PHONE_STATE permission in my manifest.

    But version 1.16 doesn't add READ_PHONE_STATE permission.
     
    Last edited: Jul 13, 2018
  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please test with IAP 1.20, we made some changes in this area.
     
    Yury-Habets likes this.
  13. dhanrajsinh24

    dhanrajsinh24

    Joined:
    May 8, 2014
    Posts:
    59
    I'm using latest Unity and latest IAP plugin and I can't remove Phone permission. I don't want to upload to Xiomi store then why do I need UnityChannel folder???
     
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please see the previous post by Yury-Habets. I suspect that although IAP itself does not require the permission, it may be triggering a scan of the project and finding assets that have not set the targetSdkVersion.
     
    Last edited: Jul 24, 2018
  15. dhanrajsinh24

    dhanrajsinh24

    Joined:
    May 8, 2014
    Posts:
    59
    @JeffDUnity3D Hi, it was coming from Chartboost SDK in the project. Thanks for your help.
     
  16. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    Since upgrading to Unity IAP v1.21.0 and the UDP addition our APK is being injected with the READ_PHONE_STATE permission. I've just unzipped the file udp.aar file and found the permission listed in the manifest file. How can we stop this infecting our main apps manifest file??
     
  17. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Do you need the UDP feature?
     
  18. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    No I don't even know what it is to be honest. We haven't used it and haven't changed any settings to use it. I've simply updated the Unity IAP package from the asset store.
     
  19. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    To temporarily get around the issue I've had to manually extract the udp.aar file, remove the READ_PHONE_STATE from the manifest and then rezip the aar file. Will this be fixed in an update, or another suggested way to fix it perhaps? thanks.
     
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  21. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    I'm not sure how else I would have known this. There's no possible way I can be across every message posted on the forum. Unity prompted me to install an update for the Unity IAP package and common practise for most software development is to grab the latest version. Presumably when v1.22.0 or newer versions come out that I do need I will still have the same issue about the UDP manifest infecting my build. It's like the advise about what we should do when new versions come out, generally go trawling though every forum post we can find to see if there's some comment that we should not use the latest version and ignore all prompts to upgrade from the editor because maybe it's a version we don't need. It's a very confusing workflow.
     
  22. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Agreed, we are working on this to make it more clear and ease the upgrade process.
     
  23. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    Thank you. I appreciate you taking this on board. Is there any advise about how to safely downgrade versions? All I can think of is to install the v1.21.0 package in an empty project, take note of what files are added to the project. Manually remove these and then install the v.1.20.0 package.... OR.... do you have to know can I simply import the v1.20.0 package over the top of v1.21.0 and everything will be ok? or some other more official way of uninstalling the Unity IAP package. I guess in the future when the Unity IAP package is located and managed entirely in the new package manger this kind of issue will be easier to address given that the package assets will be nicely organised and not spread in many places around the assets folder.
     
  24. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  25. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    Perfect, thanks.
     
  26. KATblKST

    KATblKST

    Joined:
    May 31, 2017
    Posts:
    10
    jason_yak
    Thanks for resolving. >> udp.aar <<
     
  27. mtozsahin

    mtozsahin

    Joined:
    Dec 29, 2017
    Posts:
    5
    I have ran into this issue too. Just deleted the UDP folder from Assets/Plugins, and got rid of the PHONE_STATE permission. The game seems to compile and work fine.

    Apparently i didn't need it at all. (Unity iap added it automatically for some reason)
     
    blitzcloud likes this.
  28. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @mtozsahin Please see the previous messages on this thread regarding "for some reason". Also 1.20.1 has been released which is the version that you want.
     
    KATblKST likes this.
  29. YD_JMysior

    YD_JMysior

    Joined:
    Aug 4, 2016
    Posts:
    60
    After updating my project (to Unity 2017.4.11f1) and Unity IAP plugin I also had this problem.
    I've managed to get rid of this perrmision. Unfortunately I'm unsure which one of the below steps worked:
    1. I've downgraded the SDK tools to 25 as per the point 2 in this posts answer: https://answers.unity.com/questions/1433115/android-how-to-remove-read-phone-state.html
    This alone did NOT do the trick.
    2. I've removed the IAP plugin completely (UDP, UnityChannel and UnityPurchasing folders in the Plugins folder). Later I made sure the project compiles witout it (this required quite a bit of refactoring) and reinstalled the Unity IAP 1.20.1
    3. I've added `<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25"/>` to the manifest file of UnityChannel (it did not specyfy the target sdk). I made sure the changes are saved to the UnityChannel.aar archive.

    Thanks to all the above steps my game is no longer asking the users for unthinkable things.
     
  30. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @YD_JMysior Were you using 1.21 previously? If so, that would explain it.
     
  31. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    96
    Jeff, I also updated from 1.19 to 1.20.1

    and get additional unwanted permission - READ_PHONE_STATE

    Am I right that now UDP removed from Unity IAP and I should just remove previous version of plug-in and import new one?

    Also I should not remove generated tangle files)
     
    Last edited: Oct 18, 2018
  32. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  33. blitzcloud

    blitzcloud

    Joined:
    Aug 18, 2015
    Posts:
    27
    This did it for me.