Can not load AssetBundle from a file


I’ve built asset bundle the way it is described here.

Then I’m trying to load it:

AssetBundle bundle = AssetBundle.CreateFromFile(@"path_to_folder\bundlename");

And get the error:

Error while reading AssetBundle header!

What am I doing wrong?

I had the same issue, and in my case it was because CreateFromFile was expecting an absolute path, not one relative to the executing directory.

// Assumes CreateFromFile executes from current directory - but it doesn't
AssetBundle bundle = AssetBundle.CreateFromFile("AssetBundles\\MyAssetBundle");

// This does load the bundle correctly
string dir = System.Environment.CurrentDirectory;
AssetBundle bundle = AssetBundle.CreateFromFile(dir + "\\Assets\\AssetBundles\\MyAssetBundle");

Loading using WWW class helped to solve this problem.