Log in or register to post comments

Android Split Issue with Unity3D

August 18, 2014 - 7:21am #1
Platform : Android
Engine : Unity3D
I have two scene (lets say Scene A & Scene B) which uses ARCamera and ImageTargets. The properties on both of the gameobjects are exactly the same on both the scenes. Now I followed the doc. in this link 
to load the data sets. It works on SceneB but not in Scene A. Just a pointer, if I do not split the apk it works on both the scenes. 
I get "dataset is null" for the Scene A it does not work and "dataset exists" for the Scene B where it works (logcat). Now the difference between the two scenes is that, 
Scene A:
1. There are times where I do not need the ARCamera so I search for the gameobject and deactivate/activate it. 
whereas in Scene B - I do not really touch ARCamere thro' code & it works.
CODE in Scene Ahttp://pastebin.com/M5EkTM2d
1. I wish to know what I am doing in Scene A is the right way to do it and if I am doing wrong, I wish to know what else should I do?
2. How do I load the data set in the ARCamera where it says, Dataset is null. Is there any other way of loading the data set (probably a method call)?
3. I also tried to do Resources.Load() but I see that the Load Data Set boolean and Activate boolean variable are not serialized when they are within the project hierarchy!
The iOS app is live and rolling on a very high note. I have this android build which should have been by friday but yet to be live. I have been crunching on this on the weekend too. Any help is much appreciated. 

Android Split Issue with Unity3D

August 28, 2014 - 1:00pm #6

Got it Working!


I had to use the workaround for the bug in Vuforia 3.0.5/3.0.6 rather than follow the instructions that are supposed to work for Vuforia 3.0.9.

ie this thread: https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/cant-load-dataset-obb-vuforia-3


still using 3.0.9 and Unity 4.5.1 and my Nexus 7 from 2012 with KitKat (4.4.4) and using the Unity samples 3-0-10

AllesandroB's published fix for 3.0.5/3.0.6:

I removed the code from AddOSSpecificExternalDatasetSearchDirs

I added the code to the ARCamera per scene (with dat xml hardcoded)

private bool mDataSetsLoaded = false;
private string[] mDataSetNames = new string[] {"StonesAndChips.xml"}; //replace with your dataset name
// Update is called once per frame
void Update () 
  ImageTracker itracker = TrackerManager.Instance.GetTracker<ImageTracker>(); 
  if (itracker == null) return;
  if (!mDataSetsLoaded) {
    string dataSetRootDir = Application.persistentDataPath + "/QCAR/";
    foreach(var datasetName in mDataSetNames) {
      DataSet dataSet = itracker.CreateDataSet();
      if (dataSet.Load (dataSetRootDir + datasetName, QCARUnity.StorageType.STORAGE_ABSOLUTE))
    mDataSetsLoaded = true;
I also have an empty scene for loading, where I extract the xml and dat file from the obb (streaming path) and put it in the persistent path. I use a variation on karsnen's script (find link in previous post on this thread). I put that script on an empty in the loading scene.
I make sure I have write permission on the android device.
And I split the binary.
(I also use a script that let's me switch between the scenes with a button, but that's just to test.)
Unity pushes the apk and obb down to the device
and happily it runs now, loads the files, then I go to a VR scene and it works!
I DO NOT RECOMMEND TRYING this with the Unity emulator (on Windows 8.1 in my case) as it CRASHED UNITY. It must be doing something that Android likes but Windows doesn't.
I have not yet tried to load different datasets or multiple datasets.
I have not yet tried to put some code back into empty AddOSSpecificExternalDatasetSearchDirs.
I have not yet tried to figure out how to create the OBB separate from the apk so that I can do it from my Android Eclipse build (where I have Unity/Vuforia as just one fragment in an activity, and build from the google project side)
I have not yet tried this with GooglePlay, where you download (or check if downloaded) the OBB in your code, before doing the extract of xml or dat.
But small steps...it's working in my current small setup.
Hope this helps someone else.

Android Split Issue with Unity3D

August 28, 2014 - 9:45am #5

Thank you so much for sharing your process.

Unfortunately, despte doing what you do, it's still not working for me.

I'm using the 3.0.9 Vuforia Unity extension, and one of Vuforia's Unity samples (3-0-19) as a new project, and Unity 4.5.1.

Ii use your loader (which is excellent and fast, thank you!) and the dat and xml are being put in the right spot. I confirmed that --< Application.persistentDataPath+"/QCAR".

I modify the AddOSSpecificExternalDatasetSearchDirs call to explicitly add the paths to Application.persistentDataPath and to it plus QCAR.

This is in addition the what the Vuforia team already has there for 3.0.9 samples.

I follow the checklist of items posted earlier about using split apk/obb  from the FAQ.

I have a scene loader with a regular camera and an empty with the loader script, and script to create button to go to next scene (which is Vuforia sample, no changes beyond the script modification mentioned..so the AR Camera should be active (and the datasets are checked and active)).

But nothing works if I split the binary. (except I can get the dat and xml loaded and saved to persistent storage)

If it don't split it, it works fine.

I am not using GooglePlay, but just letting Unity push the apk and obb down to the device (Build and Run) and so am using unsighed Key (debug) rather than full keystore.

I'm using a Nexus 7 (2012 version) with os 4.4.4  as my test device.  Does anyone know if it might be a OS problem?

What else should I try?  

I've been up all night trying to solve this and reading everything I can find on Unity and Vuforia forums, but nothing has helped.



Android Split Issue with Unity3D

August 19, 2014 - 9:55am #4



This is what I do in my first scene that loads. It does not have an ARCamera. 



Once the routine runs, I load the scene. Then in the ARScene once I have enabled the gameobject (ARCamera) I called that method. 




Android Split Issue with Unity3D

August 19, 2014 - 7:43am #3

Hi karsnen,

Can you give any further pointers on how you got this far? I too have followed the advice on extracting the files from the .obb to where they should be, but when I try to load the AR scene on my device it crashes. The last output on the logcat is:

"Data set MY_DATASET not present in application package, checking extended root locations"

My datasets are in the Application.persistantDataPath +"/QCAR" and I have added this directory to the search paths in 

public override void AddOSSpecificExternalDatasetSearchDirs()
AddExternalDatasetSearchDir(System.IO.Path.Combine(Application.persistentDataPath, "QCAR"));

Any help you can provide would be appreciated as I too have been stuck on this for a while, with our iOS version of the app live now.

Android Split Issue with Unity3D

August 18, 2014 - 9:47am #2

I finally found a solution. 


I just got to call this method after I activate the ARCamera. 




But anyway, as I am new with Vuforia - if any of you find my approach "NOT" the right way. Let me know. I wish to change. 




Log in or register to post comments