Search Unity

Unity 5.3 on Android M

Discussion in 'Android' started by markob, Jan 12, 2016.

  1. markob

    markob

    Joined:
    Sep 1, 2015
    Posts:
    8
    Why does unity ask at app start up for storage permission even if I need the storage permission later in my game? (using Unity 5.3) is there any way to disable this and let me ask for it when I need it?

    android unity3d
     
  2. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
  3. markob

    markob

    Joined:
    Sep 1, 2015
    Posts:
    8
    hmm but that post refers to unity 4.6 ? (I am using 5.3) think it's a separate issue, also in unity 5.0.4 this was not an issue and it worked perfectly as it did not ask for any permission. Also on Android you have to handle this anyway, because a user can always deny that permission ...
     
  4. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
    Yup because you probably updated the Android SDK. Unity detected that you used the last sdk to build and added permission dialog to your build.
    This is the same implementation for Unity 4.6 and Unity 5.3.
    We never had the problem here because we haven't updated the sdk so we are still on an sdk that doesn't handle the permissions.
    If you didn't pushed your apk with permissions on Google Play you can still go back to the old sdk(files are probably somewhere on internet)
     
  5. markob

    markob

    Joined:
    Sep 1, 2015
    Posts:
    8
    hi, yes on play it does have target 23 and can't turn back, but when I uploaded on play I used unity 5.0.4 and works ok there. (does not ask for any permission at app start and I can ask for it when I need it)... so I would think this is some kind of bug introduced in unity 5.3.1
     
  6. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
    This is not a bug, this was not handled in previous Unity versions. Now it is
     
    Yury-Habets likes this.
  7. markob

    markob

    Joined:
    Sep 1, 2015
    Posts:
    8
    unity should not ask for the storage permission until I need it, the idea behind runtime permissions is to request them when you need them and not all at app start ... unity 5.3 requests storage permission at app start even if I don't need it then
     
  8. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
    I know they are not using the permissions as Google say, but understand them, how can they know what a Plugin will do? For exemple is the Java plugin access storage directly from the plugin and not from the Unity code, they can't know that. So they made it this way to avoid "code kiddies" complaining that plugins doesn't work correctly because they don't know that the plugin must asks for permission.
    Do you understand?
     
    Yury-Habets likes this.
  9. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    This is correct. If you run Unity 5.0 with API level 23 installed, then you will have no dialog, and all the permissions actually denied. In 5.3, you will get a dialog on startup.

    What @r.pedra says is all correct. Please refer to the thread http://forum.unity3d.com/threads/unity-bug-fix-problem-android-6-urgent.367681/ for more details, or feel free to ask additional questions there.
     
  10. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    As Yury mentioned, check out that thread, it will explain the situation in more detail.
    However, if you want to stop the dialog you can use the special meta tag Unity added to suppress it.

    Code (XML):
    1. <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />
    Beware, though, that this will allow you to proceed with dangerous permissions denied. As it did in pre-Unity 5.3 I believe.
    The intent behind this tag is that you will handle it yourself and ask for the relevant permissions at run-time when you need them.
     
  11. markob

    markob

    Joined:
    Sep 1, 2015
    Posts:
    8

    Sorry what I meant is that unity should not ask for storage permissions unless it needs it, (since storage permission is optional can't see why unity would need it at app start), I should be able to add storage permission in the manifest and unity should ignore it, as I want to use my own plugin to ask for the permission and also explain to the user why I need it when I need it, and if I don't ask for the permission app should just crash ... should be the developers choice when to ask for them ... that was the point of runtime permissions
     
  12. markob

    markob

    Joined:
    Sep 1, 2015
    Posts:
    8
    thanks seems to be what I needed