Android isn't able to load Asset Bundles and I'm using Unity v5.1.1f1

Hey all,
I’m developing an app for Android, and am currently providing the user with the option to download models to their Android device. Everything works on desktop as designed, however on Android devices I get an error:
“…can’t be loaded because it was not built with the right version or build target.”
I’m using Unity v5.1.1f1, and the models are being built and exported using the same version.

Everything I’ve read states that all you have to do is identify the Buid Target (i.e. BuildTarget.Android in this case) in the ExportAssetBundles (Editor) Script.

Here is my code I’m using to export my Asset Bundle with “No Dependency Tracking”:
[MenuItem(“Assets/Build AssetBundle From Selection - No dependency tracking”)]
static void ExportResourceNoTrack () {
// Bring up save panel
string path = EditorUtility.SaveFilePanel (“Save Resource”, “”, “New Resource”, “unity3d”);
if (path.Length != 0) {
// Build the resource file from the active selection.
BuildPipeline.BuildAssetBundle(Selection.activeObject,
Selection.objects, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets, BuildTarget.Android);
}
}

Here is my code that downloads the model and saves it to the mobile device:
string savePath = Application.persistentDataPath + saveToPath;
if (!Directory.Exists(savePath))
Directory.CreateDirectory(savePath);
string filePath = Application.persistentDataPath + saveToPath + saveAs + “.unity3d”;
if (!File.Exists(filePath)) {
File.WriteAllBytes(filePath, www.bytes);:wink:
} else {
File.Delete(filePath);
File.WriteAllBytes(filePath, www.bytes);:wink:
}

And here is my script that I load the Asset Bundle from the phone:
// This loads a model from the prefabs directory
GameObject obj = Resources.Load(“Prefabs/” + thisContainer.modelName) as GameObject;
GameObject modelLoaded;

if (obj == null) {

// Attempt to load model from dynamically added directory on mobile device called “Saved Prefabs” (i.e. string saveToPath = “/SavedPrefabs/”)
string assetBundleName = Application.persistentDataPath + saveToPath + thisContainer.modelName + “.unity3d”;

AssetBundle assetBundle = new WWW(“file:///” + assetBundleName).assetBundle;

if (assetBundle != null) {
obj = assetBundle.mainAsset as GameObject;
Instantiate(obj);

Analysis:
I’ve found that the model is downloaded fine, I’ve even copied the downloaded file from my phone to my desktop, ran my Unity project and it opened without any issues. Essentially verifying that this is not a Asset Bundle export issue, but rather a mobile-only issue when I’m writing the data to the phone.

How can I write/save my downloaded Asset Bundle to the mobile device (Android) properly so I can load my models already!!!

Try yielding to complete the download operation:

WWW www = new WWW("file:///" + assetBundleName);
yield return www;
if(www.error == null){
   AssetBundle bundle = www.assetBundle;
   if (assetBundle != null) {
      obj = assetBundle.mainAsset as GameObject;
      Instantiate(obj);
   }
   else
      Debug.Log ("AssetBundle not loaded");
}
else
   Debug.Log (www.error);

Why, does that change the formatting of the Asset Bundle so it can

I meant to say, I’ve already tried this and it still produces the same error. I don’t think this is the issue since I’ve been able to download an Asset Bundle to my mobile device, move that file to my desktop environment, and successfully opened it there! In fact, I’ve tried the exact same code above that you posted, but I still get the same mobile error.
That being said, do you still think it’s a simple “yield” line of code?