- Home /
Android Download asset bundle locally
Hi All,
I try to fetch the Asset bundle stored locally on Android. After going through Unity documentation and searching through forums, these are my findings:
AssetBundle can be fetched locally on Android through UnityWebRequest or WWW classes. But the URL to be passed as parameter should be containing the "StreamingAssetsPath" followed by the bundle name.
The URL will be something similar to:
jar:file:///data/app/com.example.myapp/base.apk!/assets/myBundle
I have tried the following two approaches for my purpose:
string localUrl = System.IO.Path.Combine(Application.streamingAssetsPath, "myBundle");
Debug.Log("Local bundle path = " + localUrl);
WWW www = new WWW(localUrl);
yield return www;
if(www.error != null) {
Debug.Log(www.error);
}
else
{
Debug.Log("Local Bundle fetched.");
localBundle = www.assetBundle;
}
UnityWebRequest www = UnityWebRequest.GetAssetBundle(localUrl);
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
Debug.Log("Local Bundle fetched.");
localBundle = DownloadHandlerAssetBundle.GetContent(www);
}
However, the approaches provided above don't give the desired result. The bundle can't be fetched. Should anything more be provided to get the bundle?.
Please note that downloading asset bundles from web works fine for me. Also, fetching assets one by one by hosting them under Resources folder also works.
Your answer
Follow this Question
Related Questions
Downloaded Images using unity web request get automatically deleted in Android Devices 0 Answers
Unity 5 Resources.LoadAsync on Android slower than iOS? 0 Answers
Why do iOS web requests stop working after a few hours? 0 Answers
Save a reachable file on the android device 1 Answer
Creating an asset bundle at runtime 1 Answer