- Home /
AssetBundle.CreateFromFile() on Android not working
So we are trying to get Asset Bundles to work on Android.
The Bundles are created like this:
BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.Android);
we load them like this:
AssetBundle ab = AssetBundle.CreateFromFile(Application.streamingAssetsPath + "/StreamingAssets");
This works fine in the Editor, but on Android, it causes the following error:
Error while reading AssetBundle header!
We do not want to use WWW, since we are using uncompressed Asset Bundles and we have to care about memory consumption. Is there any other way to achieve this, or am i doing anything wrong with that CreateFromFile() ?
Unity version is 5.1.2.p3
Help much appreciated.
Comment
Answer by tangyikejunn · Aug 19, 2015 at 03:33 PM
You pass in a wrong path, it should be like this : Application.dataPath + "!assets/" + [Your file path relative to StreamingAssets]
.