Log in or register to post comments

Interesting Problem with AssetBundles

April 11, 2014 - 6:34am #1

Hi all,

We have a vuforia project with just a model and a video to augment. When we finished the app it became approx. 130mb. That's not a problem for iOS but for Android we have to use OBB as most of you know. But I searched a little about the obb splitting issues. After the search, we decided to download the model (which causes the program to be 130 mb, without the model it is only 29mb) from internet as assetbundle. 

We have managed to do that today with Unity Editors simulation platform. Everything works fine, when it sees the target it downloads the bundle (15mb, great compression) and our model is there. But when I deploy the project to an Android device it doesn't load the model. I actually don't know if it downloads the assetbundle or not. The debugs doesnt contain anything about downloading (which I put inside downloader method). 

Because of that I have tried a different method, I put the assetbundle in the streamingAssets folder and tried to extract from there. Again, it was successfull when I hit the play in Unity itself but no luck on the mobile device.

I have created the assetbundle for Android platform. So there is no problem there. I have actually done that kind of thing with previous Unity releases but now I couldn't. 

Here is the downloader code:

using System;
using UnityEngine;
using System.Collections;

public class download2 : MonoBehaviour {

	public string AssetName;
	public int version;
	public bool isFound;
	public string url;

	void Start() {


	void Update() {

		if (isFound){

			StartCoroutine (DownloadAndCache());


	IEnumerator DownloadAndCache (){
		// Wait for the Caching system to be ready
		while (!Caching.ready)
			yield return null;
		if(Caching.IsVersionCached(url, 1) == false)
			string filePathFirst = System.IO.Path.Combine(Application.streamingAssetsPath, "site.iphone.unity3d");

			WWW www = WWW.LoadFromCacheOrDownload(filePathFirst, version);
			while( !www.isDone ) {
				float m_CurrentValue = www.progress * 100;
				yield return null;
			url = filePathFirst;
			Debug.Log("Download starts");
			yield return www;
			Debug.Log("Downloading again");
			if (www.error != null)
				throw new Exception("WWW download had an error:" + www.error);
			AssetBundle bundle = www.assetBundle;
			if (AssetName == ""){
				GameObject go = Instantiate(bundle.mainAsset) as GameObject;
				go.transform.parent = GameObject.Find("ImageTargetStones1").transform;
			// Unload the AssetBundles compressed contents to conserve memory
			// Frees the memory from the web stream
			Debug.Log("Downloading again is not required....already in cache");
		// Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache


And here is the exporting assetbundles code

// Builds an asset bundle from the selected objects in the project view.
// Once compiled go to "Menu" -> "Assets" and select one of the choices
// to build the Asset Bundle
using UnityEngine;
using UnityEditor;

public class ExportAssetBundles {
	[MenuItem("Assets/Build AssetBundle From Selection - Track dependencies")]
	static void ExportResurce() {
		// Bring up save panel
		string basename = Selection.activeObject ? Selection.activeObject.name : "New Resource";
		string path = EditorUtility.SaveFilePanel("Save Resources", "", basename, "");
		if (path.Length != 0) {
			// Build the resource file from the active selection.
			Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
			// for Android
			                               selection, path + ".android.unity3d",
			                               BuildAssetBundleOptions.CollectDependencies |
			// for iPhone
			                               selection, path + ".iphone.unity3d",
			                               BuildAssetBundleOptions.CollectDependencies |
			// for WebPlayer
			                               selection, path + ".unity3d",
			                               BuildAssetBundleOptions.CollectDependencies |
			Selection.objects = selection;

I am really desparetly looking for a solution for 3 days but I ran out of options. Any help is welcomed.


Interesting Problem with AssetBundles

November 20, 2017 - 5:31am #8

be careful when you are creating Game Object ,its name must be start lowercase letter...

Interesting Problem with AssetBundles

April 11, 2014 - 10:05am #7

Sorry, the right link is this:



Concerning debug log messages, try this from the command line:

adb logcat -s Unity

This should show you the messages logged by your Unity app, and filter out everything else


Interesting Problem with AssetBundles

April 11, 2014 - 7:24am #6

Article seems to be about DataSet's not Assetbundles. But I have checked one of your clarifications about Assetbundles. The problem is I hava used some debug codes with the WWW downloader. But I can't see them on logcat even I can see them at Unity console.

Interesting Problem with AssetBundles

April 11, 2014 - 7:10am #5

Ok, then you need to debug by adding for example some log message and check if the asset returned by the WWW class is NULL, or if there are other similar issues.

Also, have you checked this article ?


This provides a working example of how to download and use Asset Bundles with Vuforia.

Interesting Problem with AssetBundles

April 11, 2014 - 7:09am #4

When I use Unity to play it it gives no error. But when I debug it with logcat here is the code when it see the target "model" (target with the 3d model)

I/Unity   (12126): Trackable model found
I/Unity   (12126):  
I/Unity   (12126): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 53)
I/Unity   (12126): 
I/Unity   (12126): NullReferenceException: Object reference not set to an instance of an object
I/Unity   (12126):   at TrackableEventHandler.OnTrackingFound () [0x00000] in <filename unknown>:0 
I/Unity   (12126):   at TrackableEventHandler.OnTrackableStateChanged (Status previousStatus, Status newStatus) [0x00000] in <filename unknown>:0 
I/Unity   (12126):   at TrackableBehaviour.OnTrackerUpdate (Status newStatus) [0x00000] in <filename unknown>:0 
I/Unity   (12126):   at StateManagerImpl.UpdateTrackablePoses (UnityEngine.Camera arCamera, .TrackableResultData[] trackableResultDataArray, Int32 originTrackableID, Int32 frameIndex) [0x00000] in <filename unknown>:0 
I/Unity   (12126):   at QCARManagerImpl.UpdateTrackers (FrameState frameState) [0x00000] in <filename unknown>:0 
I/Unity   (12126):   at QCARManagerImpl.Update (ScreenOrientation counterRotation, CameraDeviceMode deviceMode, .VideoModeData& videoMode) [0x00000] in <filename unknown>:0 
I/Unity   (12126):   at QCARAbstractBehaviour.Update () [0x00000] in <filename unknown>:0 


Interesting Problem with AssetBundles

April 11, 2014 - 7:03am #3

Actually I have created the assetbundles today with the same Unity version that I created my project. They are not from past projects. 

Interesting Problem with AssetBundles

April 11, 2014 - 6:49am #2


to my knowledge, there are 2 possible reasons for the issue you are observing:

1. The Asset Bundle is not built for the Android platform

2. The Asset Bunlde has been created with an old version of Unity and you are trying to import it with a newer version of Unity (for example, if you have created the AB with Unity 4.1 and your App is now based on Unity 4.3, this might fail, due to some version incompatibility).


Given that you have already excluded issue 1,  I guess the problem might be with issue 2. Could you check ?


Log in or register to post comments