Help Please - Question about Google Play OBB Downloader

It depends on how much risk you are willing to take.

If you target Android 4.4 and up, I’m pretty sure that every device will auto download the OBB with the main APK initially. HOWEVER, the OBB file could still be purposefully or accidentally removed from the device, or maybe it was even only partially downloaded (something funny happened during download) and in either case, the game is unplayable. Since you have no plugin to handle checking to make sure the OBB is there, the game will be useless. The user will have to uninstall and try re-downloading the app, which will erase any save data on the device.

So again, it’s all about how much risk you are willing to make. If you are expecting to make thousands of dollars from your app and it’s crucial that everything is perfect, no questions asked, I’d use the plugin. Otherwise if this is some hobby app that will get 100 downloads, don’t worry about it.

1 Like

We found that on the HTC One M8 running Android 5.0.2, among others, that the OBB was not downloaded. So you definitely need to include code to check for and download the OBB.

Also, you don’t need to use the plugin, you can quite safely make your own scene in Unity that handles it, especially if you’re able to host the obb yourself.

Hi,

One question about the obb file :

  • the Unity downloader documentation says that it will downloaded into the SD Card - but what about devices which have no SD Card ?

  • if the device downloads the .apk and the .obb files at the same time automatically, will the .obb file be downloaded into the SD Card to ? Again, what about devices without SD Card ?

Thanks

The OBB download helper script has this:

public static string GetExpansionFilePath()
    {
        populateOBBData();

        if (Environment.CallStatic<string>("getExternalStorageState") != Environment_MEDIA_MOUNTED)
            return null;
           
        const string obbPath = "Android/obb";
           
        using (AndroidJavaObject externalStorageDirectory = Environment.CallStatic<AndroidJavaObject>("getExternalStorageDirectory"))
        {
            string root = externalStorageDirectory.Call<string>("getPath");
            return String.Format("{0}/{1}/{2}", root, obbPath, obb_package);
        }
    }

SD card really has nothing to do with anything, Android knows what it’s doing.

I’ve been trying to test this, but I haven’t uploaded my test app to the Play Store (and don’t really want to just yet). Therefore, I have no public key, and I always get a security fatal exception. Can anyone recommend a way around this, please?

You get your key when you have the app store page created, doesn’t have to be published.

I’ll just post here instead of opening a new thread; we too have this OBB problem with our new project, which is just that little bigger than 100mb.
We now have our game uploaded on Google Play; after downloading and launching it, the game freezes as soon as it loads any content inside the OBB file. This happens in any publishing mode (alpha, beta, release) but with some devices only, such as Galaxy S4 and OnePlus One. What we don’t understand is why the problem solves itself after rebooting the device.
Did anyone of you discover some more on this issue?

After rebooting it works every time you open the game?

Yes, exactly.

I haven’t looked at these scripts for a long time, but I’m guessing maybe there’s some condition where it checks to see if the OBB exists or something and it’s mishandling something. Does it show any content from the OBB or just freezes when accessing it?

I’m so confused about this whole OBB process. Does this sum it up:

So if have an app over 100mb, I need to rename my OBB file to main...obb if I want it to be automatically installed with the APK. But in some cases the OBB can fail to load, user can remove it or Android is just buggy on some device and/or OS version combinations in which case a backup OBB loader is recommended. Then if you have any videos in StreamingAssets, they can’t be played from an OBB file and need to be copied somewhere where they can be played unnecessarily inflating the app install size, but if the disc space runs out and the copy fails you would perhaps show an alert… or do something else.

is that kind of what needs to happen to get an Android app releasable?! :face_with_spiral_eyes::(:roll_eyes::hushed::rage::sweat_smile::eyes::eyes::eyes:

I’m not sure about streaming assets, but yes, you want to have some code to download the OBB from Google servers in case it wasn’t downloaded properly, or whatever.

Damn… seems like such a bizarre setup. It’s such a bad user experience that users would download an app, only to find they have another monster download they need to wait for before playing. It sounds like Google realised this along the way and half way fixed this with automatic obb downloading, but why not just remove the 100mb APK limitation. Instead we’ve got a solution that mostly works, but can fail in many situations. Sigh.

I have the exact same problem as DanjelRicci in that I need to reboot my Android for the game to work properly after it has been downloaded from the Google Play store (both APK and OBB files). Has anyone else had this problem and manage to solve it? Thanks

We had an issue where we had to navigate to another Activity in the Android app for it to recognise that the OBB exists. So we made a dummy Activity which simply exit immediately and returned back to the UnityActivity. After that the OBB worked fine without a restart.

You simply have to account for the OBB not being there on start up and put in contingencies to download it yourself. You always need to rename the OBB to that convention (it baffles me why Unity doesn’t automatically). AFAIK it’s entirely up to Android / Play Store as to whether it will download the OBB automatically or not. But either way the user / other apps can delete it for whatever reason, so you should always account for it not being there.

1 Like

Could you elaborate on that ?

I’m having this issue where the app downloaded from google play needs a phone restart to recognize the obb, failing to see a reason why…

1 Like

I don’t have the code anymore but I basically created an AAR with an activity that in it’s onCreate (may be remembering that method name incorrectly) it closed itself and returned to the Unity activity.

For people that stumble on this thread due to the obb restart issue, I found this guide for creating an aar for Unity. Gonna try creating an empty activity that launches the first time the game is run / after the obb download to see if that can consistently fix this issue.

Did you have any success ?

I tried but was unable to have a fix for this issue, still marking my games as requiring read_external_storage to have them work without restart, which is very annoying.

Hey there… out of interest what Android OS version and device are you testing with? If Android 6 or newer does the issue only resolve after the user permits the read permission?

There’s a very similar thread going on over here that I’ve been adding findings to as well: https://forum.unity3d.com/threads/apk-with-expansion-file-obb-fails-to-load-the-second-scene-until-the-phone-has-been-restarted.465714/#post-3130969