Search Unity

Issue with Google Play OBB Downloader

Discussion in 'Android' started by peerssa, Aug 13, 2015.

  1. peerssa

    peerssa

    Joined:
    Aug 13, 2015
    Posts:
    5
    I'm really hoping this is something someone else has come across and fixed, because this has now been a bugbear for the last few days.

    So our app is 96MB, which means we have to use the OBB splitter, which works perfectly. Splits where it should, runs fine when files in place. Upload to Google Play, again, runs fine once downloaded.

    The issue is where we try and simulate the use case of the OBB file being deleted, or not downloaded automatically. To account for this, we have tried to include the OBB downloader from Unity Asset Store. Now, if the file is there, it finds it, registers it as there, and carries on as normal.

    However when its not, the app just kicks back out to launcher with no message, no sign of the downloader dialog.

    The main issue with this, is the only place this should work, downloading off the store using beta/alpha section of the store, means we cannot use debug output, so its not easy to see what is going on. Has anyone come up against this??

    Here is the downloader code:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DownloadObb : MonoBehaviour
    5. {
    6.     private string expPath;
    7.     private string logtxt;
    8.     private bool alreadyLogged = false;
    9.     private bool downloadStarted;
    10.  
    11.     public Texture2D background;
    12.     public GUISkin mySkin;
    13.  
    14.     public bool loadedSafely = false;
    15.  
    16.     void log(string t)
    17.     {
    18.         logtxt += t + "\n";
    19.         print("MYLOG " + t);
    20.     }
    21.     void Update()
    22.     {
    23.         if (!GooglePlayDownloader.RunningOnAndroid())
    24.         {
    25.             Debug.Log("Use GooglePlayDownloader only on Android device!");
    26.             return;
    27.         }
    28.  
    29.         expPath = GooglePlayDownloader.GetExpansionFilePath();
    30.         if (expPath == null)
    31.         {
    32.             Debug.Log("External storage is not available!");
    33.         }
    34.         else
    35.         {
    36.             string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
    37.             string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath);
    38.             if (alreadyLogged == false)
    39.             {
    40.                 alreadyLogged = true;
    41.                 Debug.Log("expPath = " + expPath);
    42.                 Debug.Log("Main = " + mainPath);
    43.                 Debug.Log("Main = " + mainPath.Substring(expPath.Length));
    44.                
    45.                 if (mainPath != null)
    46.                     StartCoroutine(loadLevel());
    47.  
    48.             }
    49.             //GUI.Label(new Rect(10, 10, Screen.width-10, Screen.height-10), logtxt );
    50.            
    51.             if (mainPath == null)
    52.             {
    53.                 Debug.Log("Attempting download");
    54.                 //choice to download here?
    55.                 GooglePlayDownloader.FetchOBB();
    56.                 StartCoroutine(loadLevel());              
    57.             }
    58.  
    59.         }
    60.  
    61.     }
    62.  
    63.     protected IEnumerator loadLevel()
    64.     {
    65.         string mainPath;
    66.         do
    67.         {
    68.             yield return new WaitForSeconds(0.5f);
    69.             mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
    70.             Debug.Log("waiting mainPath " + mainPath);
    71.         }
    72.         while (mainPath == null);
    73.  
    74.         if (downloadStarted == false)
    75.         {
    76.             downloadStarted = true;
    77.  
    78.             string uri = "file://" + mainPath;
    79.             Debug.Log("downloading " + uri);
    80.             WWW www = WWW.LoadFromCacheOrDownload(uri, 0);
    81.  
    82.             // Wait for download to complete
    83.             yield return www;
    84.  
    85.             if (www.error != null)
    86.             {
    87.                 Debug.Log("wwww error " + www.error);
    88.             }
    89.             else
    90.             {
    91.                 loadedSafely = true;
    92.             }
    93.         }
    94.     }
    95.  
    96. }
    This is a modified version of DownloadObbExample.

    Our level loader sits and waits for 'loadedSafely' to turn true, then loads the next scene.

    Here is a list various 'fixes' we have tried:
    • Updating GooglePlayDownloader from GitHub to latest
    • Adding 'intent.Call<AndroidJavaObject>("setPackage", "com.android.vending");' to GooglePlayDownloader before the addFlags intent call
    • Checked the public key is in correct place - all fine
    • Attempted to get running using debug outside of the store environment - apparently this can't work, and testing seems to confirm this as the only 'URL' it returns on output is the local path of the expected OBB
    • Set up test account, made sure it had the correct permissions on the dev portal. Then sent it a beta invite. Deleted all other account data on target device, using only test account on the phone.
    Does anyone have any suggestions, or even a way of getting debug output from a release build? Outputting text to screen is impractical due to the app kicking out so fast, and this is a VR title, so would not be easily readable.
     
  2. the_game_maker

    the_game_maker

    Joined:
    Nov 15, 2014
    Posts:
    65
    It may be a lot harder but you could try hosting the file online instead of downloading it.
     
  3. the_game_maker

    the_game_maker

    Joined:
    Nov 15, 2014
    Posts:
    65
    Or you could build the whole all file and host it on Say media fire then show a link to download the whole file if the expansion file doesn't download