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 Bug Fix - Problem (Android 6) - Urgent

Discussion in 'Android' started by MrEsquire, Nov 13, 2015.

  1. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    Thank you for the feedback @sekari and @MrEsquire !

    The solution with SkipPermissionsDialog metadata should not be considered as a final one. Google may change some things in the next Android versions, so we will implement a better permission handling workflow. However, we will unlikely remove this metadata flag support not to break backward compatibility.

    I think I already posted that, but will do it again.
    At the moment, we have to ask for all the permissions on startup, in order for all the plugins to work correctly.
    We can implement an async request for permissions when you need them in Unity code, but if you use an old plugin that does not act the same, you will end up with no permissions for it at all.
    So, with the powerful plugin system, we see no solution at the moment but ask for all the permissions on startup.
    In future Android version Google may add more callback features, and we will redesign the workflow on our side.

    What's wrong with the black background when asking for permissions? If you want your own permission handling system - feel free to add the metadata tag, and write a plugin of your own that will show the dialog on a nice background. The dialog is displayed by Android OS by the way.

    @MrEsquire - last 4.7 version has all the M permission handling features as 5.3. You can use the default dialog on startup, or silence it and make your own. There are no plans to improve it right now, until we get an Android update.

    Hope this answers your questions/concerns.
     
    sekari likes this.
  2. sekari

    sekari

    Joined:
    Jan 13, 2015
    Posts:
    27
    Thank you so much for your answer @Yury Habets ! The problem with SkipPermissionsDialog tag is that I couldn't have found any reliable resource/documentation about it, therefore it wouldn't be rational to write a native plugin to handle permissions without knowing how Unity will react when I use that tag. I am actually pretty happy that you guys introduced such a quick solution to this issue. My complaint was related to the documentation of the solution at all.

    Have a nice day!
     
  3. Svirsky

    Svirsky

    Joined:
    Sep 16, 2015
    Posts:
    5
    Thanks for your response, I wonder if you planning to drop this permission in the future as on Android 6.0+ app own saved files can be accessed using context object.
     
  4. qbrandon

    qbrandon

    Joined:
    Jun 27, 2015
    Posts:
    2
    Our application uses the following permissions:
    Code (XML):
    1. <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    2. <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    For which we took the time to implement runtime handling.
    We have tried including
    Code (XML):
    1. <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />
    but found that no matter where in the manifest we would include it (activity or application), the permission (for contacts) is still systematically requested upon startup.
    We are working with Unity 5.3.1 (currently p4 but we have tried this with previous patch revisions with similar results)
    Are we missing something?
     
  5. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @qbrandon : this feature hasn't still made it into 5.3. It's already in 4.7, latest 5.2 and latest 5.4. I've submitted the change for 5.3, hope it will be there really soon. Stay tuned and read the release notes!
     
  6. qbrandon

    qbrandon

    Joined:
    Jun 27, 2015
    Posts:
    2
    @yury-habets : Thank you for these precisions, we will test this with 5.4b3, and look forward to a release version (5.3.1pX or 5.4.0f1) that can handle this (I am afraid going back to 5.2 and below is not an option for now)
     
  7. dippnsk

    dippnsk

    Joined:
    Feb 12, 2015
    Posts:
    8
    It's 5.3.2p2 already and the change is not even there. Can someone raise the priority of this in 5.3 patch release schedule? It's actually quite critical problem for all Android 6.x devices. No one wants to see all that permission requests at the very start of a game.
     
  8. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    5.3.2p3 is supposed to have this change.
     
  9. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
    The permission system itself is bad.
    Why bother people with permissions that they don't understand and that will increase the amount of bug or misunderstandings of the user.

    For example, if you have a photo app. You will have to ask for storage access.
    What happened if the user doesn't understand and keeps telling you he doesn't want you to access storage?
    He will come to your app comments, give you 1 star and say "doesn't work, don't download".

    I think a group of geeks worrying too much about permissions and privacy are just annoying millions of people with things they doesn't care of.

    I don't what Google could do differently about that but this is definitely not the right way to do it. (And I'm an owner of Nexus 6P, and I'm bored about about all these apps asking me my permission to access storage or camera to take a photo, or asking me for my permission to access contacts if I explicitly clicked on a button that needs to access contacts to do what it is supposed to do).
     
  10. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,630
    Yeah, but that's an android problem, not a Unity problem.

    I think the way android 6 is set up, it's designed to make the users paranoid about permissions. (maybe to distract from the fact that you're sending all your stuff to google? :p )

    Even the prompts reinforce the paranoia. The prompt for WRITE_EXTERNAL_STORAGE, which is needed for the OBB Downloader, says something like "This app wants access to your photos!". Then you get users asking why you need their photos.
     
    bluescrn likes this.
  11. cjdeas

    cjdeas

    Joined:
    Dec 19, 2012
    Posts:
    1
    I have a question about what happens when a user denies one of the dangerous permissions that Unity now brings up automatically on the black screen at the start. It looks like to us that game continue to load if they reject the permissions? That doesn't seem like it should be case. How do we handle preventing them from loading in without writing a custom plugin? Note: we are getting 3 permission popups, one for external storage, one for phone, one for contacts. Rejecting external storage leaves us at black screen, probably because the obb can't download, but rejecting one of the other two allows us to continue loading. Confused. Any help appreciated.
     
  12. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
    Did you watch in Monitor what is happening? Maybe device logs could help you
     
  13. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @cjdeas : please check your logcat for any errors. Could be that for obb we'll have to write a separate case with write external storage permission.
     
  14. URself

    URself

    Joined:
    Dec 27, 2012
    Posts:
    9
    Hi
    I just upgraded my Unity from 4.6.9p1 to 4.7.1f1. I created a new apk to upload to play store and
    I see this error and doesnt let me publish the new apk

    This configuration cannot be published for the following reason(s):

    • It is forbidden to downgrade devices which previously used M permissions (target SDK 23 and above) to APKs which use old style permissions (target SDK 22 and below). This occurs in the change from version 200 (target SDK 23) to version 201 (target SDK 21).
    I did go through some of the post in here. My question is it the changes that are needed for Android 6 pushed to 4.7.1f1?
    Should I downgrade my unity version to 4.6.9p1 and make a new build?

    Thanks
     
  15. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    This particular permission seems quite ridiculous.

    It just doesn't seem right that any app over 100MB has to request a permission with such a hostile message, when the only files that we want access too are in an application-specific folder.

    Surely an app should automatically have full access to its own data, even if the rest of the filesystem is off-limits?
     
    MrEsquire likes this.
  16. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    I been saying long time before Unity really need to rethink about the permission system as a whole.

    There are plugins on the asset store that help the user manage the AndroidManifest scripts.
    Unity should have a system within the build options that tells the user exactly what PERMISSIONS are registered and required once the .apk is built (permission management).

    For bigger apps, splitting the app into a .obb is a must and users have no option on Google Store.
    Now there option to access internal only and external storage, some phones dont have external storage.
    So there again is this confusion of which permission or if both needed.
     
  17. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    I agree with the points about the permission system (though it's applicable to the new Android permission system as a whole). Hope there will be improvements in Android N. We will think of the ways to improve the workflow. Thanks for the feedback!
     
  18. beer_money

    beer_money

    Joined:
    Feb 28, 2013
    Posts:
    8
    Hi,
    release notes 4.7 say:
    • Android: Added support for Marshmallow OS runtime permissions. Added possibility to disable permission dialog by adding activity metadata.
    I get the entry in the manifest for disabling permissions on start up but where's the support for runtime permission? Is there an API for this? or are we expected to write/copy a plugin to do this?
     
  19. beer_money

    beer_money

    Joined:
    Feb 28, 2013
    Posts:
    8
    For what its worth, here's the guidelines on how to handle the new permissions:

    "The Android 6.0 (Marshmallow) release allows users to directly manage app permissions at run time. Because of this, it’s important to handle permissions properly in case a user has denied access to some or all of the required permissions. Be sure to follow the guidelines below when implementing a permission request flow:
    • Avoid requesting permissions at launch unless they are critical to the app running.
    • If any permissions must be requested at launch, be sure to provide context to the user as to why they are being asked to allow it.
    • When possible, trigger the requests at the time of the associated action.
    • In the event of a user denying a permission request, avoid immediately directing the user to the app settings. Instead, educate the user as to why the app needs the permission to run and provide a way to re-trigger the request in the app. Reserve sending a user to the app settings until the app has detected that the 'Always deny' option has been selected."

    You'll need to do this if you have a chance at a feature!
     
  20. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    It's fairly easy to poll the permission state and request permissions at runtime - requires you to create a plugin with just a few lines of Java. But interpreting and responding to the permission state in a sensible way is more tricky. Especially when you're dealing with 'no permission = app can't continue' (WRITE_EXTERNAL_STORAGE for OBB usage). Google seem to assume that all permissions should be optional, and that you'll never have case where the app simply can't continue without a specific permission.

    if shouldShowRequestPermissionRationale() returns false and the permission is not currently granted, you could be in two different states:

    1) Permission is 'blocked' (has been denied, with 'don't ask again' selected). Google don't want you to display a rationale message in this case... but if the app can't continue, you kind of need to display a message of some kind.

    2) It's the first run of the app, and we've never requested the permission yet. In this case, you need to request the permission, and Google don't want you to display a rationale message. (But it may make sense to display a message, if the permission is essential to the app running)

    There's no way to check which of the two states it's in - unless you know that it's the first launch of your app (e.g. from saved data)

    I couldn't figure out a way to use 'onRequestPermissionsResult' in the Java code. This has to be in your main activity (it doesn't seem to be supported yet by the Prime31 activity sharing system - and we're relying on a few P31 plugins)

    This StackOverflow thread is worth a read: http://stackoverflow.com/questions/...sion-how-to-determine-if-the-user-checked-nev
     
  21. marcomarchesi

    marcomarchesi

    Joined:
    Apr 11, 2016
    Posts:
    1
    Adding <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" /> to the manifest fixed the not needed permission requests but also the app can't connect anymore to internet. I guess I have to add an explicit permission request also for that, is it correct?
     
  22. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    Internet access shouldn't require a runtime permission request, but still requires the network-related permissions in your manifest ("android.permission.INTERNET" and "android.permission.ACCESS_NETWORK_STATE")

    These are 'normal permissions', not 'dangerous permissions':

    https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous

    The recent Android game that I worked on ended up only needing a single runtime permission request for the 'dangerous permission' WRITE_EXTERNAL_STORAGE (which seems to be needed if you're dealing with OBB files?)
     
    Yury-Habets likes this.
  23. marchesi

    marchesi

    Joined:
    Jun 12, 2015
    Posts:
    1
    Finally I fixed it. But I had to try three different versions of Unity (5.2.4 - 5.3.3 - 5.4.0), all implementing the meta-tag solution for Android Marshmallow permissions. The reason is that the Unity project I was working on was made with 5.3.1 and was not working correctly with 5.2.4 (no internet connection anymore, I don't know why) and 5.4.0 (some assets was not loaded properly). Only the 5.3.3 version has guaranteed proper functionality.
     
  24. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    It is not advised to make a project on one version of Unity and then release/open it on OLDER version, of course this is common sense and you will get issues. It seems like you opened project in many different versions and messed some of your files. To not go offtopic, best to always use latest Unity version 5.3.5 at time of writing and all the meta as needed.

    Of course I still see no improvement in 5.4 or any mention of future updates, lets see if Unity make any announcement at Unite.
     
  25. skaarjslayer

    skaarjslayer

    Joined:
    Oct 10, 2013
    Posts:
    108
    Another useful feature would be for Unity to support handling the permission responses for permissions that are requested at game launch so we can comply with Google's "best practices" for Android M permission flow. This means being able to show native dialog to either provide context to the user for why we need a permission or explain why the app cannot continue functioning without that permission and close the game. There are other games that can already do this. For now, the solution seems to be to use the meta-tag to bypass Unity's permissions solution and implement permissions ourselves... which works, but makes the handling of Android M permission flow a lot more difficult than it needs to be.

    For example, if there's game-critical permissions I may want to prevent the user from playing my game or at the very least show a native dialog explaining why the game needs it, and I'd want that dialog to occur pre-splashscreen. Unity's permissions requests do occur pre-splashscreen but does not handle any of the responses to those permission requests so I can't have any native dialog appear to give any context or explanation to the user after they deny or allow the permission. This forces me to use my own plugin solution within Unity which is a bother because that requires moving beyond the splashscreen when I'd rather do what Unity does and have the dialog appear pre-splashscreen. I suppose I could export to an Android project and handle that natively, but I'd much prefer a Unity solution.

    Just some feedback because right now getting Unity to comply with Google's best practices for Android M permission flow is proving to be difficult.
     
    Last edited: Jun 17, 2016
  26. r-pedra

    r-pedra

    Joined:
    Dec 4, 2015
    Posts:
    104
    Guys, Look a this : https://github.com/sanukin39/UniAndroidPermission
    We just used it in our game and it works like a charm. We extracted the code to merge it with our own UnityPlayer override activity, but still easy to use and customise because the guy gives the code.

    Only problem is with Applicaiton.persistantDataPath but if you go to Issue tab of GitHub, he gives a solution to this problem(with errors inside, but easy to find, some copy paste errors)
     
    AcidArrow likes this.
  27. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167
    @SkaarjSlayer : I've already explained that multiple times. We can do it to explain the permissions added by Unity. But we can't guarantee anything if you are using the plugins - so current solution is the safest. I admit that it is not the most user-friendly solution, but we need to prevent sudden crashes. This is why we are exposing the ability to manage the permission for our users via the metadata manifest value.
     
    MrEsquire likes this.
  28. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,167