Or just remove the whole metadata tag.
I just read today patch notes :
- (none) - Android: Fixed the issue where OBB was not available after installing from Google Play on some phones until device was restarted.
How did you guys managed to fix it ???
Downloading it now to test.
I just did a quick test and the issue was not fixed.
Unity now âproperlyâ asks for the read permission, but if the user denies it the game will still fail to load the obb content.
Basically the âfixâ was not helpful, we still need to force the user to give the proper permission, the way unity implemented the permission request is also not proper, google requires us to say somewhere why we are asking for the permission, the unity permission request does not show the reason.
The fix is to add READ_EXTERNAL_STORAGE permission. Of course, if the user denies it - OBB loading will fail.
Iâve explained multiple times why we are asking for permissions at startup instead of a âdynamicâ permission system. This is actually one good example when the permission must be asked as early as possible (before OBB is being loaded).
If you want to implement a dynamic permission system, you may want a plugin, like this GitHub - Over17/UnityAndroidPermissions: Unity Android Runtime Permissions for Android Marshmallow .
Is there available any fix for Unity 5.6.1 I used some asset store products which donât have version for unity 2017 if I switch to newer version my 6 month work I can put into trash because I will have to rewrite many things from scratch :(.
I tried repair it on my own. I tried to add
and it ask me for permission when I build game in my phone through usb in unity editor, but when I publish it to Google Play and install it on phone it not ask for permission and game wonât work.
I see you posted link to plugin where it is written
âUse Android Studio to build the AAR from the source in src/ directory.â
I completly donât know what is AAR , never used Android Studio, always worked on unity and now to fix some unity issue I have to do this in external tool :(. Well just at least please write some better instruction for less experienced user how to fix this step by step for Unity 5.6.1
Maybe I misunderstood instruction but do Iâve to build this plugin in adroid studio before use in unity or I can just copy it to my folder and thats all ?
I guess you didnât understood what I meant, the explanation I am talking about is that we have to put a message somewhere, currently weâre doing it on the first scene of the build, that says to the final user, that we require permission to access his files because the expansion file needs it to read game data, this is a requirement by Google itself, if you donât do this, and only asks for the permission as unity does in itâs default state (not giving the reason for the user), your game cannot be featured on the play store, because itâs a Google requirement to explain why the permission is being asked.
Thatâs why Iâm saying the current solution by unity is not proper, because :
1 - It allows the user to deny the permission, which will make the game unplayable, the âcorrectâ(only?) solution would be to prevent the game from continuing to load if the user denied the permission, we currently deny android users from continuing to the next scene unless he accepts the permission, thereâs no way around it. If the user checks the âdonât ask againâ checkbox, then we open the game settings window in the android so he has to manually allow it there.
2 - As I said above, the unity permission request window doesnât explain why the permission is needed for the end user, as was said before :
@JustAnotherDude I know the Google requirements with regard to permissions. Once again, Iâve explained multiple times why we donât support it out of the box.
Iâve talked about this:
Android: Fixed the issue where OBB was not available after installing from Google Play on some phones until device was restarted
The fix for this issue (OBB not available until phone restart) is to add READ_EXTERNAL_STORAGE permission - this is what Unity does for you now. It has nothing to do with the dynamic permission system at all.
Also, due to the moment when we mount the OBB (before engine initialization), you have to have the permission at very early stages of the game.
What I used in 5.6.1 was changing
to
Just removing it didnât work for me because then unity puts the defalult
ââ
into the manifest when it makes the build.
I think I finnally resolved this problem with plugin provided by Yury-Habets so I decided to write simple tutorial so others wouldnât have to struggle with this ;). And I hope RafaelF82 it also cover answer for your question too
1.First we have to override unity generated android manifest file and it is simple. Basically this file shows in Temp/StagingArea/AndroidManifest.xml during build , then copy this file after build to Plugins/Android. Every is covered in this video tutorial
.
2.Then I add 3 lines
First in Activity tag
And another two after tag
Write permission maybe isnât necessary (you can experiment) but I add this and it is working so I left it that way.
3.Then is this part which was hard for me when I started but now I see is simple. Download this plugin
4.Just copy Assets folder to your project Assets folder - plugin is ready to use
5.In my project in first scene in Start() I added
CheckPermission();
And the function is
public void CheckPermission()
{
if (!GetComponent().CheckPermissions())
{
Permisssion.SetActive(true);
}
else
{
//this else part isnât necessary
print(âpermission grantedâ);
}
}
MyPermissionCheck is just this example file UnityAndroidPermissions/Assets/Scripts/AndroidPermissionsUsageExample.cs at master ¡ Over17/UnityAndroidPermissions ¡ GitHub
renamed by me , plus my few changes. And how it works
This function check obviously if the permission is granted GetComponent().CheckPermissions()
This function CheckPermissions() in MyPermissionCheck
public void OnGrantButtonPress()
{
AndroidPermissionsManager.RequestPermission(new[ ] { STORAGE_PERMISSION }, new AndroidPermissionCallback(
grantedPermission =>
{
GetComponent().Permisssion.SetActive(false);
},
deniedPermission =>
{
GetComponent().Permisssion.SetActive(false);
GetComponent().PermisssionDenied.SetActive(true);
}));
}
And this are my UI panels for Permission In Permission Denied,
For Quit buttons I just add Application.Exit() function for Yes Button
I connect in unity Editor (In Button Script On clik section) this OnGrantButtonPress().
So when first scene starts, the star funtion in my main obejct (where scripts are attached) firing this CheckPermission() if permission are granted
just do nothing and move on if not then Permission panel appear and Uuser decide (he get info why permissions is needed) If he click Quit then application Quit
if he click Yes then OnGrantButtonPress() and Android Dialog show up when user can click allow or deny. If click allow then Permission palog is hidden
and game move on if clicks deny then PermissionDenied panel shows up whit info that without this permission user canât play + button to Quit application.
So RafaelF82 you can fire CheckPermission() function on start application or when you need this additional permissions.
You can check in my application how It works
I hope it will help others so they donât have spend many hours like I to solve this.
Iâm sorry for âtyposâ but forum doesnât allow me to edit and correct my post :(.
I think thereâs a lot of misunderstanding going on in this thread.
The solution you posted is the same Iâve been using since I detected the bug, but this is not a proper solution, as none of us can actually fix the bug, because itâs a bug in android, as posted here : https://issuetracker.google.com/issues/37075181
This is why Iâm saying unity did not fix the bug, because asking for the permission is not the solution, the user can deny it and the game will not run, this is why I have been doing as you are, asking for the permission myself and preventing the user from going forward into the game if he denies it, the result is that Iâve already received some 1 star reviews in the store because I require the permission, when I shouldnât even have to ask for it in the first place if android wasnât buggedâŚ
The worst part is that google is refusing to accept it as a bug and fix the android OS, because apparently this is a bug that happens on all devices except their nexus devices, they are investigating the issue again here : https://issuetracker.google.com/issues/37544273
Hope they recognize the issue and fix it now.
I got it to work using Unity 5.6.2 and changing the manifest âSkipPermissionsDialogâ to false (thanks** 265lutab**!):
I can also confirm that this fix no longer works using Unity 2017.0.1f3!
I am using Unity 2017.1.0f3 and I have the same problem. In my VR game, I have to restart the phone for obb file to work. I donât think that there is a problem in the Android version. Everything works OK on LG G3 but restart is necessary on Xiaomi Redme Note 4. They both have Android 6 installed. Any suggestions?
You have to have the write external store permission. In API 19 they removed the need to ask for this permission to store the obb file on the sdcard. But in android 6 there was a regression bug that brought the issue back. The problem is that the obb file does get stored but doesnât have the correct user permissions so is unreadable by the app. Restarting resolves the file permissions. But having the write external storage permission there negates the issue, however it will unnecessarily add horrible user facing permissions to your play store listing.
This issue Iâve spent weeks researching different work arounds, itâs my single biggest annoyance with the android SDK and I believe Google could completely solve it in a retroactive way if theyâd allow single apk installations over 100mb and they simply reworked how the over the air 100mb installation limitation is enforced, they already have a warning popup when youâre using mobile data so thereâs no reason for this apk file size limitation anymore. Other android based platforms around the world donât have this horrible 100mb apk limitation and these large apk files install and run perfectly fine. Remove the need to use OBB expansion files I say, life would be much simpler.
So⌠adding to manifest should help? I thought that read external storage is enoughâŚ
Read will be enough for this particular permissions bug. But you have a second issue that by using obb files a percentage of devices will fail to install the obb file and is where you require a backup obb file loader. For this you need write permission, so you may as well add that. Itâs pretty easy to replicate. Install your app on any Samsung phone running android 6, uninstall it, reinstall, the app gets installed but not the obb this time around. Obb files are so painful!!
You need to be doing proper install tests via the play store btw⌠uploading the apk and obb and testing them via the beta channel. Youâll see the issue occur pretty quickly.
Here here!
Just to expand on DaReignâs answer for anyone else who needs to go through this pain:
The bug should be fixed in Nougat and above (at least according to the documentation here Context | Android Developers), but apparently it still occurs for some people. In our game, we check if the primary obb file can be read, and if it canât, then the permissions dialog will popup. If the primary obb file can be read, then we shouldnât need to ask for any permissions. This extra check is good so that devices that donât have this bug wonât need to ask for the READ_EXTERNAL_STORAGE permission.
Had to write a native android plugin for that, you can find the code here Extensions.java ¡ GitHub
Another thing is that if youâre using the UnityAndroidPermissions plugin (GitHub - Over17/UnityAndroidPermissions: Unity Android Runtime Permissions for Android Marshmallow), after receiving the permission granted callback, you should wait til the next Update loop to actually change scenes. If you donât, the obb will not be correctly loaded. I think this is because the actual permissions are flushed only after the callbacks are called. This seems like a bug in the plugin though, it should probably flush first and then call the callbacks.
Edit: We ended up actually having to restart the app after accepting read permissions for the first time as we were getting extremely odd bugs - UI elements were sometimes getting loaded and sometimes not, even for the same assetsâŚ
You can do this in java by setting a PendingIntent alarm to start the app up in X seconds and then exiting the app immediately. The app will be restarted again once the alarm is activated. Hereâs the code for that Extensions.java ¡ GitHub Our app is now live and everything seems to be going well.
Oh, and you can test the changes locally without having to wait 5 hours to upload to Google Play. First, you download the app from the play store and reproduce the bug. Your obb file should have ârootâ as the owner, which means the app canât read it without permission. Now, install an updated apk and replace the old one (make sure the version codes of both apks are the same). The old obb should still be there with root permissions. Note that you wonât be able to test with this obb, since obbâs must match the apk they were built with.
If you upload a new obb into that folder, it should also have root permission, which is great, because it means you can test the permissions locally without uploading an alpha/beta build on google play.
Maybe one day google will remove their apk size limit and we wonât ever have to deal with this again.
EDIT: Just wanted to quickly mention that this android bug sometimes does not occur. Iâve had it not occur for over a week when downloading from the google play store, but then itâll come back eventually at some point. This makes me think that this bug is isolated to specific google play servers. If this is true, then this is vital in fixing the issue on googleâs side because it means some servers already have the fix in them!