Android Apk + Obb Splitting | Scene is not loading

Hi there,

as it seems I have a problem with splitting my application to .apk and .obb files.
I have followed this tutorial and all went fine so far…
I can create the spitted files and I can successfully download the .obb in my first scene.

But after the download I can’t load the next scene (which is inside the .obb as I assume). When it comes to loading the next scene I get the following error message:

Level ‘02_menues’ (1) couldn’t be loaded because it has not been added to the build settings.

I saw that I am not the only one expiring this problem, but I didn’t found any working solution.

So far I have tried things like:

  • using c# code only
  • putting all scenes in a “Resource” folder
  • removed all scenes from the build settings and added them again
  • rebuild and reuploaded the apk/obb to google several times

… but none of these things worked…
Crazy enough: if I push the app to the phone via Unity (build and run) it is working…but not if downloaded from Google. I don’t get what I’m doing wrong.


  • Unity Documentation regarding obb
    splitting

  • Asset store tool I use

  • The code I use:

    using UnityEngine;
    using System.Collections;

    public class DownloadObbExample : MonoBehaviour
    {
    private string expPath;
    private bool downloadStarted;

      void Start()
      {
      	expPath = GooglePlayDownloader.GetExpansionFilePath();
      
      	if (expPath == null)
      	{
      		//Error
      		System.Console.WriteLine("
    

OBB DOWNLOAD: External Path not found
");
return;
}
else
{
string mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
string patchPath = GooglePlayDownloader.GetPatchOBBPath(expPath);

			System.Console.WriteLine("

OBB DOWNLOAD: External Path: " + expPath +"
“);
System.Console.WriteLine(”
OBB DOWNLOAD: Main Path: " + mainPath +"
“);
System.Console.WriteLine(”
OBB DOWNLOAD: Patch Path: " + mainPath +"
");

			if (mainPath == null)
			{
				System.Console.WriteLine("

OBB DOWNLOAD: Main was null and OBB will be fetched now
");

				GooglePlayDownloader.FetchOBB();
				
				System.Console.WriteLine("

OBB DOWNLOAD: OBB has been fetched
");

				StartCoroutine(loadLevel());
			}
			else
				Application.LoadLevel("02_menues");
		}
	}
	
	protected IEnumerator loadLevel()
	{
		string mainPath;
		
		do
		{
			System.Console.WriteLine("

OBB DOWNLOAD: Trying to fetch main path
");

			yield return new WaitForSeconds(0.5f);
			mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
			
			System.Console.WriteLine("

OBB DOWNLOAD: Main path = "+ mainPath + "
");

		}
		while( mainPath == null);
		 
		if(downloadStarted == false )
		{
			System.Console.WriteLine("

OBB DOWNLOAD: Load OBB from mainPath: “+ mainPath +”
");

			downloadStarted = true;
		 
			string uri = "file://" + mainPath;
		
			WWW www = WWW.LoadFromCacheOrDownload(uri , 0);
		 
			// Wait for download to complete
			yield return www;
			
			System.Console.WriteLine("

OBB DOWNLOAD: OBB loaded. Procede to next level…
");

			Application.LoadLevel("02_menues");
		}
	}

Well it seems that my problem has been solved by waiting for Google to update the .obb + .apk file.
If anyone of you experience the same problems that just rebuild your apk and obb files and commit them to Google. You should then wait for about 1-2 hours and test your application download again.

As far as I can say, the first obb file you commit is available instantly, but if you update the apk and obb files it will take a while till they are available. In this period of time you will receive the wrong obb file and get the error described above (the apk you manually push to the device doesn’t match with the downloaded .obb).

Cheers!

I’ve got the exact same problem that Straafe describes. Mine can’t be to do with waiting for Google to propagate it as I left it for a week and it quickly shows the download screen saying Download Finished then loops back to the first screen. Anyone been able to get around this?

EDIT: I think I found the problem with this; in Player Settings, I hadn’t changed the Write Access to ‘External (SDCard)’. Silly mistake, I know, but it makes a huge difference!

Try either of these two things…

In Player Settings, change the Install location to Force Internal and Write access to Internal only

To get it working with external access (i.e file read and write), I would suggest try adding the android.permission.WRITE_EXTERNAL_STORAGE permission to your Android manifest. (Although I haven’t confirmed if this works). But my guess is if you don’t have this permission, and because the files being accessed were in the OBB in External storage (default player setting), they weren’t found.