Cocos2d-x Runtime permissions on Android now mandatory

Hello,

As u many know already or not yet :slight_smile:

Starting from tomorrow u can’t submit in Google Play Android apps which targeting lower then Android sdk 26, which means on all Android 6.0+ devices u need to handle permissions requests in runtime, Android manifest permission will not work on them.

So far it was discussed there: Screen Shots on Android -> writable path? and

@mars3142 created demo app with runtime permissions https://github.com/mars3142/cocos2dx-runtime-permission .

Just in case someone have some more code to share or @slackmoehrle maybe sdkbox will take care of it :wink: this is good place to share your solution and experience with runtime permissions.

Thanks. I shared this with the team.

The team is aware of this and are currently researching possibilities.

2 Likes

I’ll think, there will be no “silver bullet”, because it’s bad behavior (at least on Android) to ask for all permissions at startup. So the team should bundle the requests to the something like FileUtils::getInstance()->getWritablePath(), but this would be tricky.

At the moment, I didn’t know any “good way” to build something universal for that. Someone wants to show a custom dialog before the native one and other devs are not aware of it, because they do not develop primarily for Android. I wouldn’t know how to handle it in iOS :wink:

There should be a really good API doc, but no automated way, in my opinion.

Unity games right now just asking on launch for all permissions it needs, so user are aware of this behaviour so not big deal :smiley: but yes would be cool to have possibility trigger permissions manually.

I know many games, who did it wrong, but it’s really bad, because the game has to also check for permission if it uses “dangerous” APIs or they completely block the usage of the game - even worse.

I would recommend the “Unity way” (as an Android developer).

As i know AndroidMenifest.xml includes all permissions needed, should the app also ask for the permissions again in codes?

Hi,yes if app is compiled against SDK 23+ in gradle it is

   targetSdkVersion 23
   compileSdkVersion 23

In this case on all Android devices 6.0+ they ignore “risky” permissions in Android manifest and u need to request them in runtime when user launching app. Risky permissions is read/write external storage for example.