Unity 5.3 bundles - "Unable to open archive file"

I get this “Unable to open archive file” error whenever I try to load an asset bundle using AssetBundle.LoadFromFile or AssetBundle.LoadFromFileAsync.

This is happening in the OSX editor.

The error happens with both LZMA and LZ4 compression, and only with the new AssetBundle.LoadFromFile functions. Loading bundles with WWW still works.

:(:(:frowning:
my game is upgrade unity5.3.0f4
and running in ios load scene and load some abs will cause this error too!!!:rage::rage:

i have fix this error, you cant cached a lot assetbundle runtime…
make sure unload your assetbundle after load assets.

Having this same issue (5.3.0f4, 5.3.1f1, etc). Android works fine. On iOS (iPadMini, iPad2, etc linked to XCode), downloading bundles fine for the first few then run into this crash/exception:

Unable to open archive file for writing: ‘/var/mobile/Containers/Data/Application/2144CC8A-6BDD-4CF8-801C-658688275CCE/Library/UnityCache/Temp/347cd6c4f87084f18afe6f8b04f40bd1/__data’

After this error, receive another within XCode:

Failed to decompress data for the AssetBundle ‘file:///ASSETPATH.unity3d’.

This is only happening when trying to access the asset for the first time. After the asset is cached (have to restart the app after the error), we’re able to get past. However… with more bundles, this happens again and again until each asset is cached appropriately.

This may or may not be related to the amount of bundles loading/unloading as we haven’t had this issue with prior full releases of Unity.

EDIT
This is due to LoadFromCacheOrDownload.
(Unity - Scripting API: WWW.LoadFromCacheOrDownload)

Anyone know of a solution? @Unity?

1 Like

Just throwing my hat in the ring that we are also seeing this in a published WebGL build (not editor). We are using LoadFromCacheOrDownload.

I just ran into this but not using LoadFromCacheOrDownload. I’m using AssetBundle.LoadFromFileAsync. AssetBundle.LoadFromFile works fine. I’m thinking its to do with my compression setting. I’ll try LZ4 format later.

Same problem here.

Unity5.3.1p4

In UnityEditor try load assetbundle use AssetBundle.LoadFromFileAsync and AssetBundle.LoadFromFile will get error:
“Unable to open archive file” :hushed::hushed::hushed:

all assetbundle are rebuild in Unity5.3.1p4 and tried with different setting (compressed,chunk-compressed,uncompressed)

but everything works fine with WWW !!! :eyes::eyes::eyes:

:(:(:frowning:
please help dear Unity!

Try removing the “file://” from the path. This fixed the issue for me in 5.3.1p4.

4 Likes

thank you koyoki! i will give it a try!

yes…loadfromfile, not like www, should remove “file://”

_< me stupid

hank you koyoki! i will give it a try!

yes…loadfromfile, not like www, should remove “file://”

???

remove file:// can work file ?

Was this issue every resolved. I’m still seeing this on iOS on Unity 5.3.4p1.

I’m getting this error in 5.3.3 editor on OSX.

Actually ignore that. My folder was named Streaming Assets and should have been StreamingAssets.

It works for me on OSX. Have you tried running the same code on an iOS device?

As I said, ignore it. It was my mistake.

Hi Andymads, can you confirm whether you got this working on an iOS device or only in the OSX Editor? Thx!

@ratmat2002 Got it working on both OSX editor and iOS device. Unity 5.3.3.

My only mistake was an incorrectly named folder.

Would you mind posting the piece of code you are using to load the AssetBundles from the StreamingAssets folder? I’m still getting the “Unable to open archive file” error.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;

public class LoadFromFileAsync : MonoBehaviour
{
    public RawImage rawImage;

    void Awake()
    {
    }

    IEnumerator Start()
    {
        Debug.Log(Application.streamingAssetsPath);

        var bundleLoadRequest = AssetBundle.LoadFromFileAsync(Application.streamingAssetsPath+"/001");

        yield return bundleLoadRequest;

        if(bundleLoadRequest.assetBundle==null)
        {
            Debug.LogError("Failed to load bundle");
        }
        else
        {
            var assetNames = bundleLoadRequest.assetBundle.GetAllAssetNames();
            foreach(var name in assetNames) Debug.Log(name);

            var assetLoadRequest = bundleLoadRequest.assetBundle.LoadAssetAsync<Texture2D>("4334013");

            yield return assetLoadRequest;

            if(assetLoadRequest.asset==null)
            {
                Debug.LogError("Failed to load asset");
            }
            else
            {
                Debug.Log(assetLoadRequest.asset.name);

                rawImage.texture = assetLoadRequest.asset as Texture2D;
            }

            bundleLoadRequest.assetBundle.Unload(false);
        }
    }
}

And obviously make sure you have a root folder named StreamingAssets in your project.

1 Like

Andymads, thank you for the code snippet.

I finally figured it out. The path when loading from files are CASE-SENSITIVE. Arg!

Just a couple of notes on your example code:

  1. It appears that you are not including the ‘.unity3d’ file extension when using LoadFromFileAsync. I think this is necessary for proper loading.

  2. I am using BuildAssetBundleOptions.ChunkBasedCompression which now appears to load properly.

Andy

1 Like

Just a reminder, we don’t have an official file extension “.unity3d” for asset bundle, it’s not mandatory. You can use whatever file extension as you want, or without file extension.

But usually people use “.unity3d” as the file extension just because we used it in the official sample code at first time…

2 Likes