Search Unity

Unity 5.3 bundles - "Unable to open archive file"

Discussion in 'Editor & General Support' started by koyoki, Dec 9, 2015.

  1. koyoki

    koyoki

    Joined:
    May 15, 2015
    Posts:
    8
    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.
     
  2. ChiuanWei

    ChiuanWei

    Joined:
    Jan 29, 2012
    Posts:
    131
    :(:(:(
    my game is upgrade unity5.3.0f4
    and running in ios load scene and load some abs will cause this error too!!!!:mad::mad:
     
  3. ChiuanWei

    ChiuanWei

    Joined:
    Jan 29, 2012
    Posts:
    131
    i have fix this error, you cant cached a lot assetbundle runtime..
    make sure unload your assetbundle after load assets.
     
  4. littlemuggo

    littlemuggo

    Joined:
    Apr 29, 2009
    Posts:
    13
    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.
    (http://docs.unity3d.com/ScriptReference/WWW.LoadFromCacheOrDownload.html)

    Anyone know of a solution? @Unity?
     
    Last edited: Jan 4, 2016
    nhimmisha likes this.
  5. sirrus

    sirrus

    Joined:
    Jun 10, 2012
    Posts:
    250
    Just throwing my hat in the ring that we are also seeing this in a published WebGL build (not editor). We are using LoadFromCacheOrDownload.
     
  6. AshyB

    AshyB

    Joined:
    Aug 9, 2012
    Posts:
    191
    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.
     
  7. busterbeam

    busterbeam

    Joined:
    Feb 22, 2013
    Posts:
    2
    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" :eek::eek::eek:

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


    but everything works fine with WWW !!! o_Oo_Oo_O


    :(:(:(
    please help dear Unity!
     
  8. koyoki

    koyoki

    Joined:
    May 15, 2015
    Posts:
    8
    Try removing the "file://" from the path. This fixed the issue for me in 5.3.1p4.
     
  9. busterbeam

    busterbeam

    Joined:
    Feb 22, 2013
    Posts:
    2
    thank you koyoki! i will give it a try!

    yes..loadfromfile, not like www, should remove "file://"


    >_< me stupid
     
  10. peixiaohu

    peixiaohu

    Joined:
    Feb 28, 2015
    Posts:
    5
    hank you koyoki! i will give it a try!

    yes..loadfromfile, not like www, should remove "file://"


    ???????????????????


    remove file:// can work file ?
     
  11. ratmat2002

    ratmat2002

    Joined:
    Jun 13, 2014
    Posts:
    35
    Was this issue every resolved. I'm still seeing this on iOS on Unity 5.3.4p1.
     
  12. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    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.
     
    Last edited: Mar 31, 2016
  13. ratmat2002

    ratmat2002

    Joined:
    Jun 13, 2014
    Posts:
    35
    It works for me on OSX. Have you tried running the same code on an iOS device?
     
  14. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    As I said, ignore it. It was my mistake.
     
  15. ratmat2002

    ratmat2002

    Joined:
    Jun 13, 2014
    Posts:
    35
    Hi Andymads, can you confirm whether you got this working on an iOS device or only in the OSX Editor? Thx!
     
  16. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    @ratmat2002 Got it working on both OSX editor and iOS device. Unity 5.3.3.

    My only mistake was an incorrectly named folder.
     
  17. ratmat2002

    ratmat2002

    Joined:
    Jun 13, 2014
    Posts:
    35
    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.
     
  18. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. public class LoadFromFileAsync : MonoBehaviour
    7. {
    8.     public RawImage rawImage;
    9.  
    10.     void Awake()
    11.     {
    12.     }
    13.  
    14.     IEnumerator Start()
    15.     {
    16.         Debug.Log(Application.streamingAssetsPath);
    17.  
    18.         var bundleLoadRequest = AssetBundle.LoadFromFileAsync(Application.streamingAssetsPath+"/001");
    19.  
    20.         yield return bundleLoadRequest;
    21.  
    22.         if(bundleLoadRequest.assetBundle==null)
    23.         {
    24.             Debug.LogError("Failed to load bundle");
    25.         }
    26.         else
    27.         {
    28.             var assetNames = bundleLoadRequest.assetBundle.GetAllAssetNames();
    29.             foreach(var name in assetNames) Debug.Log(name);
    30.  
    31.             var assetLoadRequest = bundleLoadRequest.assetBundle.LoadAssetAsync<Texture2D>("4334013");
    32.  
    33.             yield return assetLoadRequest;
    34.  
    35.             if(assetLoadRequest.asset==null)
    36.             {
    37.                 Debug.LogError("Failed to load asset");
    38.             }
    39.             else
    40.             {
    41.                 Debug.Log(assetLoadRequest.asset.name);
    42.  
    43.                 rawImage.texture = assetLoadRequest.asset as Texture2D;
    44.             }
    45.  
    46.             bundleLoadRequest.assetBundle.Unload(false);
    47.         }
    48.     }
    49. }
    50.  
    And obviously make sure you have a root folder named StreamingAssets in your project.
     
    NarcissusEmbodied likes this.
  19. ratmat2002

    ratmat2002

    Joined:
    Jun 13, 2014
    Posts:
    35
    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
     
    MrBunny likes this.
  20. Deleted User

    Deleted User

    Guest

    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...
     
    ErayT and k1ljcore like this.
  21. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    I'm using BuildPipeline.BuildAssetBundles and the created files do not have an extension. No problem loading them for me.
     
  22. Gizmoi

    Gizmoi

    Joined:
    Jan 9, 2013
    Posts:
    327
    @Vincent Zhang This should probably be mentioned in the docs. As the example there uses:
    Code (CSharp):
    1. Path.Combine(Application.streamingAssetsPath, "myassetBundle")
    which I fails as Application.streamingAssetsPath includes "jar:file:///" on Android.
     
  23. awnuxcvbn

    awnuxcvbn

    Joined:
    May 26, 2013
    Posts:
    5
    Watch your assetbundle file suffix!
     
    prayshouse likes this.
  24. Yang-Yunyu

    Yang-Yunyu

    Joined:
    Feb 4, 2015
    Posts:
    1
    I have same error too!show the info"Too many open file" meanwhile
     
  25. banyango

    banyango

    Joined:
    Mar 31, 2014
    Posts:
    19
    Just wanted to add, I was running into this today with AssetBundle.LoadFromFile and AssetBundle.LoadFromFileAsync

    I had the asset bundle folder on a different drive (D: drive) from my project. Moving it to the same drive seems to have cleared up the issue.
     
  26. pilot888

    pilot888

    Joined:
    Jan 18, 2018
    Posts:
    1
    I have the same problem. when I build game in WEBGL. How can WEBGL load local AssetBundle
     
  27. Wothanar

    Wothanar

    Joined:
    Sep 2, 2016
    Posts:
    122
    having problems with downloading from server assets bundles i used webrequest and www and both send me failed to recieve data . any one knows a solution? its suddenly happens sometimes on 34% on 80% or 22% or 15% and just restart and restart and never getting the files.... all was working cool like 2 days ago but now the maps dont want to finish the download and im F***ed up coz this is a business proyect that i get paid for :(
     
    CloudyVR likes this.
  28. ebubeud1996

    ebubeud1996

    Joined:
    Mar 31, 2018
    Posts:
    6
    I had this same issue. I fixed it with the way I was accessing the directory where the asset bundle was stored. I Used AssetBundle.LoadFile(@"C:\mydirectory\myassetbundle") rather than AssetBundle.LoadFile("C:\mydirectory\myassetbundle"). So I added @ before the directory string. I hope this works for you guys.