Search Unity

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

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

  1. sandbaydev

    sandbaydev

    Joined:
    Aug 9, 2013
    Posts:
    68
    First of all, thanks @Yury Habets for taking time to answer.

    Secondly, sorry, but maybe I do not understand. Or I am too inexperienced with Unity android. I did not mean to distort your words. The issue here (at least for me) is not whether Android code has changed or not. The only issue is that unity Android builds are different in v5.0 versus v5.1. Now it seems that there are some new services that require those.

    It might be that I'm asking this in a wrong forum, and this is not Android specific problem. I apologize if that's the case. I'm currently building only on Android so noticed the issue only with android.

    That's great. I really appreciate the hard work you do. Unity is an amazing tool.

    That's good news. Thanks for the information.

    And that means that at least 1 out of 3 will be changed in v5.2:
    - android.permission.READ_PHONE_STATE

    Just to make sure I'm on the same page on this. Does your reply mean that it will be possible to make Android builds without these 2 permissions in Unity v5.2?
    - android.permission.INTERNET
    - android.permission.ACCESS_NETWORK_STATE

    Thanks.
     
    asnaneosman likes this.
  2. asnaneosman

    asnaneosman

    Joined:
    Apr 23, 2013
    Posts:
    3
    they are already exist in 5.2
    - android.permission.INTERNET
    - android.permission.ACCESS_NETWORK_STATE

    you can't remove as i have seen.
     
  3. sandbaydev

    sandbaydev

    Joined:
    Aug 9, 2013
    Posts:
    68
    I don't think v5.2 is yet available. 5.1.2 is the newest version?
     
  4. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    5.2 is in beta, version Beta 3 ( so please check this version)
     
    sandbaydev likes this.
  5. asnaneosman

    asnaneosman

    Joined:
    Apr 23, 2013
    Posts:
    3
    i have already checked with 5.2.
    problem still exists in version 5.2 .
    you can disable analytics but it does not remove internet access permission.
    with a new project, blank scene, there is always internet access permission for android export.
     
    sandbaydev likes this.
  6. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    987
    Is android.permission.READ_PHONE_STATE still forced in 5.2? (this is what this thread topic says at least)
     
    sandbaydev likes this.
  7. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    468
    I've just noticed this behaviour today on our new project, went to Issue Tracker and found there is an entry but it's marked as Won't Fix and decided to check forums and found the thread...

    While it's a good move if Read_Phone_State not required in 5.2, I'll also need that in 5.1.x branch as 5.2 release is few months away.

    And the same thing is true for other two permissions. We're mostly making apps targeting kids and parents are usually very picky regarding the app permissions. As we're not using any kind of internet access, tracking or analytics, we'd prefer our apps free from those permissions if possible.

    I think I can remove those manually but it would be best if Unity does not add them by default.
     
    sandbaydev and MrEsquire like this.
  8. Aedy

    Aedy

    Joined:
    Dec 31, 2014
    Posts:
    2
    Does this mean in Unity 5.2, both Personal and Pro editions, it will be possible to disable analytics and remove these permissions?
     
  9. sschan

    sschan

    Unity Technologies

    Joined:
    Oct 8, 2014
    Posts:
    87
    Hi folks - Apologies on the delay as I'm working with Unity Analytics Engineering team to better understand the issue and provide an accurate response on how these permissions interact with Analytics. I will update the Forum once I've completed my conversations. Thanks for your patience. :)
     
  10. Nethekurse

    Nethekurse

    Joined:
    Oct 29, 2013
    Posts:
    4
    Same problem here. I need to remove Read_Phone_State from my app...
     
  11. kalonw

    kalonw

    Joined:
    Feb 11, 2014
    Posts:
    4
    I wrote a simple python script that you can use to strip it out of your apks until Unity posts a fix. https://gist.github.com/kalonw/b0258ef68b7b029ce8a4 you need apktool, zipalign (in android build tools), and jarsigner available from the system path/in the same directory as the script. run it from the same folder that you build your apk to
     
  12. sschan

    sschan

    Unity Technologies

    Joined:
    Oct 8, 2014
    Posts:
    87
    Hi folks - Thanks for your patience as I looked into the permissions with the Analytics Engineering team. The permissions are partially related to Unity Analytics. There are additional Services products that use these permissions. I am only able to comment on how these permissions interact with Analytics. For 5.2 release, READ_PHONE_STATE is fixed. However, INTERNET and ACCESS_NETWORK_STATE are related to hardware stats collection and can not be disabled unless you are a Pro user.

    The permissions settings do not exist in 5.0 if you wish to use that version of the Engine.
     
    Nethekurse, sandbaydev and MrEsquire like this.
  13. PhoenixTalon

    PhoenixTalon

    Joined:
    Aug 26, 2012
    Posts:
    13
    Thank you for a straight and truthful answer. I think we already figured out that was the case, but it's good to finally have it in writing from a well informed source.

    I still don't like the internet and network, but it's easier to explain.

    Thank you again for the explanation.
     
    Nethekurse and sandbaydev like this.
  14. sandbaydev

    sandbaydev

    Joined:
    Aug 9, 2013
    Posts:
    68
    Thanks @sschan for a clear reply.

    Sucks to hear this... but I paid nothing so can't really whine about this. Sticking to 5.0 for now.
     
    Cromfeli and Nethekurse like this.
  15. plottsjp

    plottsjp

    Joined:
    Apr 2, 2015
    Posts:
    13
    @sschan is there any way to disable Unity Analytics in Unity Pro 5.103f? Additionally, what other Services products use the READ_PHONE_STATE permission?

    Thank You for your help.
     
    Nethekurse likes this.
  16. X-rus

    X-rus

    Joined:
    Oct 10, 2014
    Posts:
    13
    How donwndrade project from 5.1 to 5.0?
     
    Nethekurse likes this.
  17. Nethekurse

    Nethekurse

    Joined:
    Oct 29, 2013
    Posts:
    4
    I would also like to know if this is possible.
     
  18. 62316e

    62316e

    Joined:
    Aug 20, 2014
    Posts:
    7
    Unity, why do you hide that information?

    You just making magic changes without providing any notifications and documentation.

    Is there any explanation why this so critical bug is not explained in the docs?

    Please fix until 5.2!

    P.S. As always new Adobe do breaking changes... Hope you will be disabled in Firefox too.
     
  19. sandbaydev

    sandbaydev

    Joined:
    Aug 9, 2013
    Posts:
    68
    - I had 5.1
    - I downloaded 5.0
    - I made backup of my project
    - Opened my 5.1 project using 5.0
    => worked for me.

    I could not downgrade 5.1 to 4.7. Got just empty scene and whatnot.
     
    aer0ace and Nethekurse like this.
  20. mark71

    mark71

    Joined:
    Jun 14, 2015
    Posts:
    41
    Is 5.0 still being updated with bug fixes? I haven't seen any patch releases lately.
     
  21. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    No, 5.0.4 was the last version, which makes sense to me.
    Excluding this issue of course.
     
    asnaneosman likes this.
  22. Nethekurse

    Nethekurse

    Joined:
    Oct 29, 2013
    Posts:
    4
    Thanks, this worked for me !!
     
  23. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,084
    I was unable to get my project working when rolling back from Unity 5.1.1 to Unity 5.0.x. So, I decided to try and export the project for Android Studio. I unfortunately have some issues getting this to work with Unity Ads though. I described the error I get here. Has anyone else gone this route?
     
  24. asnaneosman

    asnaneosman

    Joined:
    Apr 23, 2013
    Posts:
    3
    i am using 5.0.4f1.
    there isnt such problem.

    do not use upper than 5.0.4f1 to avoid problem.
     
  25. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,084
    That's what I mean by "roll back". My project has already been converted to 5.1.1, which means this is not an option for me, because I tried it and it didn't work in my case.
     
  26. mpinol

    mpinol

    Unity Technologies

    Joined:
    Jul 29, 2015
    Posts:
    315
    I created a small guide on how to remove READ_PHONE_STATE permission from your app. The workaround is to use Android Studio to manually remove the permission from the application, if you do not have it installed you can download it here, https://developer.android.com/sdk/index.html, and then build the apk in Android Studio.

    • In your Unity project go to File-> Build Settings

    • Check the Google Android Project box and then click Export to export the project to a directory




    • Open Android Studio and import the exported file by going to File -> New -> Import Project and select the directory created by exporting the Unity project.



    • Choose a directory to house the new Android project.

    • Click Finish.



    • Open the AndoirdManifest.xml file.



    • Delete the READ_PHONE_STATE permission and android:debuggable lines.





    • Save the changes and then go to Build -> Generate Signed APK



    • Click Next


    • The next window will ask you for a key store. If this is your first time using Android Studio you will need to create a new key store, which you can do in this window by clicking Create new... If you already have one fill in the relevant information.



    • If you are creating a new key store fill in all of the relevant information.



    • Click ok

    • Click next

    • Choose the destination directory of your built APK and click Finish.



    • The signed apk should be named app-release.apk in whichever directory was specified in the previous step.

    • When the apk is installed the READ_PHONE_STATE permission should no longer be present.
    Just to clarify, this guide is for removing only the READ_PHONE_STATE permission and does not apply to anything else. This is a temporary workaround until we can implement a proper solution.
     
    Last edited: Aug 6, 2015
    satchell and MrEsquire like this.
  27. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,084
    This is a fantastic step-by-step, mpinol. I appreciate the promptness and thoroughness of the response. Unfortunately, this doesn't help me. While I have been successful building and running my Android APKs without UnityAds, try running a generated APK with UnityAds. I'd like to know the results.
     
  28. Naamani

    Naamani

    Joined:
    Jan 13, 2015
    Posts:
    19
    Tried the solution by @mpinol , managed to remove the READ_PHONE_STATE but got some new permissions:
    - Approximate location
    - Modify data on SD
    - Find accounts on this device.

    I don't get it,it's not in my manifest. What's the problem?
     
  29. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,084
    Have you looked at all AndroidManifest.xml files? There may be more than just one that get merged from numerous sources.
     
  30. mpinol

    mpinol

    Unity Technologies

    Joined:
    Jul 29, 2015
    Posts:
    315
    Hi @aer0ace and @Naamani,

    @aer0ace,

    Do you receive any errors when attempting to build a project in Android Studio with UnityAds?

    @Naamani,

    I believe your issue might result from extra dependencies in the build.gradle files in the Android Studio Project.
    Can you PM me the contents of both these files so I can look a little further into this.
    Capture.PNG
     
  31. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,084
    Yes.

    If I build via Gradle after importing the project, I get the following error:

    I was able to get around it somewhat by specifying

    Code (csharp):
    1. minifyEnabled false
    for both my Game project and the UnityAds project, though, I'd rather not go that route, because to my understanding, that's essentially circumventing Proguard obfuscation.

    With that temporary workaround, I then get this error:

    So I also decided to try the .IDEA project that gets exported from Unity, I was able to compile, but I couldn't run from the debugger. I can't assign an Activity to launch from the AS debugger, with the error "Default Activity Not Found". AS doesn't allow me to select "UnityPlayerActivity.java" even though it is indeed an Activity.

    I can only deploy the apk to my device, and attempt running it from there, at which point, it crashes with this error:

    Which is essentially saying the same thing as me being unable to select the Activity in the debugger.

    Now, this problem may be closer to fixable, since this error has been documented in a few places. I've read that it's possible that the UnityPlayerActivity target specified in androidmanifest conflicts with the UnityPlayerActivity in one of the Unity jars. I doubted that because the full package path was specified in the androidmanifest, but I tried renaming the activity UnityPlayerActivity2 as a test, and wasn't successful. Beyond this, I have no leads for moving forward.

    EDIT:
    Also, I wanted to thank you @mpinol for responding to these issues. I realize the READ_PHONE_STATE has a fix targeted for 5.2, but some of us, like me, are trying to update our apps sooner than that. The more knowledge everyone has on exporting and building the Android project the better.
     
    Last edited: Aug 7, 2015
  32. Naamani

    Naamani

    Joined:
    Jan 13, 2015
    Posts:
    19
    I got only one "AndroidManifest.xml" in the Android studio project :(
     
  33. mpinol

    mpinol

    Unity Technologies

    Joined:
    Jul 29, 2015
    Posts:
    315
    This workaround is only for 5.1 version and how to remove READ_PHONE_STATE as related to Unity Analytics. I am on the Unity Analytics team and only able to comment on how this works for Unity Analytics. For questions on Unity Ads and these permissions please post in the Ads Forum for assistance. As a reminder in 5.2 release, READ_PHONE_STATE is fixed as it pertains to Unity Analytics.
     
  34. 62316e

    62316e

    Joined:
    Aug 20, 2014
    Posts:
    7
    When updating to 5.1 i don't remember that i gave any permission to read my personal data or users data. It sounds like you dont want to help us understand what's going on. What analytics? Phone numbers?

    Its sounds like: "Pay or we will use your data for our needs"... i never expected such lame behavior from Unity side... Shame on you. How end users can accept your license?
     
  35. zehreken

    zehreken

    Joined:
    Jun 29, 2009
    Posts:
    106
    Does any one of the 5.2 beta builds include the fix for READ_PHONE_STATE?
     
  36. mpinol

    mpinol

    Unity Technologies

    Joined:
    Jul 29, 2015
    Posts:
    315
    Hi @zehreken,

    As of 5.2.0f1 the fix for READ_PHONE_STATE and Analytics stripping will be included.
     
  37. zehreken

    zehreken

    Joined:
    Jun 29, 2009
    Posts:
    106
    Thank you for the answer, I'm currently using Unity Analytics in my game.
     
    mpinol likes this.
  38. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    987
    Hi all,

    Here's a quick update on the status:
    - with 5.2 final version to be released soon, only INTERNET permission is added on an empty project;
    - I've made a fix for INTERNET permission for 5.3, and it is planned to land in 5.2 and 5.1 patch releases shortly (however not in the final 5.2 release!). Please stay tuned;
    - Unfortunately fix for READ_PHONE_STATE and ACCESS_NETWORK_STATE is unlikely to appear in 5.1 because it requires some huge code changes. Please consider upgrading to 5.2 if possible.

    Hope this makes things more clear.
     
    aer0ace, mh114, mdrotar and 1 other person like this.
  39. mark71

    mark71

    Joined:
    Jun 14, 2015
    Posts:
    41
    Is this the fix for "hardware stats collection" to allow it to be switched off in Unity Pro?
     
  40. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    987
    @mark71 no - this is related to the new UNET assembly (UnityEngine.Networking.dll).
     
  41. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    987
    One more update:
    In 5.1.3 Patch 2, READ_PHONE_STATE permission should no longer be required. Please let us know if that does not work for you.
     
  42. Naamani

    Naamani

    Joined:
    Jan 13, 2015
    Posts:
    19
    When will it be released? currently the latest I get is 5.1.3p1
     
  43. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    987
    I would expect next week.
     
  44. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,084
    I just tried 5.1.3f1 and I still see READ_PHONE_STATE as one of the permissions. I'm not familiar with the build id, but I would think that 'f' is for 'final'? If not, how can I get a hold of 5.1.3p2?
     
  45. mdrotar

    mdrotar

    Joined:
    Aug 26, 2013
    Posts:
    377
    Patch releases with a 'p' come out after the final release. 5.1.3p2 isn't out yet but it will be available here https://unity3d.com/unity/qa/patch-releases?version=5.1 when it is.
     
  46. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,084
    I can confirm that 5.1.3p2 has the fix for removing the READ_PHONE_STATE permission. Thanks for the hard work and transparent communication, Unity Technologies team!
     
    Yury-Habets likes this.
  47. rainbow_design

    rainbow_design

    Joined:
    Aug 8, 2015
    Posts:
    108
    Hi folks - Thanks for your patience as I looked into the permissions with the Analytics Engineering team. The permissions are partially related to Unity Analytics. There are additional Services products that use these permissions. I am only able to comment on how these permissions interact with Analytics. For 5.2 release, READ_PHONE_STATE is fixed. However, INTERNET and ACCESS_NETWORK_STATE are related to hardware stats collection and can not be disabled unless you are a Pro user.
    It does sound a bit like some kind of hardware tracking does it mean unity collects informations from Android with every Project? Has Unity gone into the same collect all - selfdestruction mode as google did long ago?

    I as Developer want at least to be able to let the user opt out of it!

    Q: I play a game built with Unity software, what should I know?
    A: Unity has probably collected some or all of the following information about your device: Unique device identifier generated from the device MAC/IMEI/MEID (which we immediately convert into a different number using a one way hash); IP address; Device manufacturer and model; the operating system and version running on your system or device; browser type; language; the make of the CPU, and number of CPUs present; the graphics card type and vendor name; graphics card driver name and version (example: "nv4disp.dll 6.10.93.71"); which graphics API is in use (example: "OpenGL 2.1" or "Direct3D 9.0c"); amount of system and video RAM present; current screen resolution; version of the Unity Player; version of the Unity Editor used to create the content; a number describing whether the player is running on Mac, Windows or other platforms; and a checksum of all the data that gets sent to verify that it did transmit correctly; application or bundle identification ("app id") of the game installed. Some Unity developers use Unity’s analytics and ad services which collect additional information. See FAQs on Unity Analytics and Unity Ads below.
    Actually i am not savy about laws but does this not mean every App must include your privacy policy too?

    • We use Google Analytics to understand how our sites are used and to improve experiences within the Service. If you want to know more about how Google Analytics works or to exercise choice in regard to the data collected by it please visit http://www.google.com/policies/privacy/partners/. In order to control the collection of data for analytical purposes by Google, you may install the Google Analytics Opt-out Browser Add-On.
    Ahh no wonder i get on facebook ads for Unity tutorials.
     
    Last edited: Sep 7, 2015
  48. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    If you have a PRO ACCOUNT, then you can, just untick the box in the build options.
    I assume this should disable the need to access permissions - if it does not then its a separate bug.
     
  49. Denvery

    Denvery

    Joined:
    Mar 26, 2014
    Posts:
    17
    ACCESS_NETWORK_STATE is fixed in Unity 5.3! I've tried on our projects
     
    Last edited: Sep 9, 2015
  50. Honikou

    Honikou

    Joined:
    Feb 18, 2013
    Posts:
    89
    android.permission.READ_PHONE_STATE is still present on our project... :mad: