Log in or register to post comments

Vuforia and Splitting APKs (OBB)

January 23, 2017 - 3:38pm #1

Hello,

I have been working on making Vuforia work with an APK that has an accompanying OBB file. I have tried several solutions presented by  users in forums (see below) but have had no success so far. I have attached the script I am using on the next page, and there is a comment (//ERROR HERE) where the script seems to break. This script is activated in the very first scene, 2 scenes before any AR is actually being used. It seems to be unable to locate the files in the Streaming Assets Data Path in the first place to actually copy them across.

using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.SceneManagement;

public class AllowVuforiaAndOBBToWork : MonoBehaviour {

    void Awake()
    {
        StartCoroutine(GetWorking());
    }

IEnumerator GetWorking()
    {
        Debug.Log("Started transferring data");
        //Create array with names of files to extract data from
        string[] filesInOBB = { "QCAR/EcologyGame.dat", "QCAR/EcologyGame.xml" };

        foreach (string fileName in filesInOBB)
        {
            //Create the two strings for the files current location and the files target location
            string uri = Application.streamingAssetsPath + "/" + fileName;
            string targetFilePath = Application.persistentDataPath + "/" + fileName;
            Debug.Log("PERSISTENT DATA PATH = " + Application.persistentDataPath + "/" + fileName);
            Debug.Log("STREAMING ASSETS PATH = " + Application.streamingAssetsPath);
            //Check if the directories exist, if not then create them
            if (!Directory.Exists(Path.GetDirectoryName(targetFilePath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(targetFilePath));
                Debug.Log("Creating path because it does not exist + " + targetFilePath);
            }
            //Write across the data to the new location
            WWW www = new WWW(uri);
            //yield return www;
            if (!www.isDone)
            {
                yield return new WaitForSeconds(5f);
            }
            if (www.error != null)
            {
                //Error here
                Debug.Log("<======================== WWW error" + www.error);
                yield break;
            }
            File.WriteAllBytes(targetFilePath, www.bytes);
            Debug.Log("File written");
        }
        Debug.Log("<=========================Files have been written=======================>");
        SceneManager.LoadScene(1);
       
    }
} 

So with this, my questions are: 

    Where should the OBB be pushed to?

    For testing, do people reupload to Google Play each time?

Also, the bundle identifier in the streaming assets path is coming out as com.COMPANYNAME.PROJECTNAME-1, what does the ‘-1’ mean? Could this path be causing issues?

 

I have already read through the posts that contain this issue with no luck. If anyone could please provide a full script example and an explanation of how they got both to work together nicely, it would be much appreciated

Forums Posts Tried:

https://developer.vuforia.com/forum/faq/unity-how-can-i-handle-large-android-apps

https://forum.unity3d.com/threads/using-obb-expansion-files-with-vuforia.271267/

Vuforia and Splitting APKs (OBB)

November 11, 2018 - 9:24pm #3

Thanks, your script works excellent. I want to ask you if you work with videos, what do you need to do for it works.

Vuforia and Splitting APKs (OBB)

January 23, 2018 - 7:32am #2

Hello. You need to name your .obb file "main.BundleVersionCode.com.YourCompany.AppName.obb" and put it manually here - "InternalStorage\Android\obb\com.CompanyName.AppName". I attached a script that I found somewhere on the forums here, and it works. And you dont need to upload files to google each time to test application. Just install your app and copy your .obb to path i wrote before.

AttachmentSize
Plain text icon ARFix.txt2.73 KB
Log in or register to post comments