- Home /
Problems get OBB File form GooglePlay Store
Hello everybody!
I´ve working for two Days on this Problem know, and dont get even closer. So I´m really appriciate if somebody could give me a hint. Thanks in advance!
In a nutshell: I have an apk thats bigger than 50MB I want to use OBB file + assetBundle to adress this problem. AssetBundle Loading is working if I copy the odd file with the right name in the right Folder. But if I try to get the OBB file from GooglePlay, I see: Download -> Download finished, but I still dont get any data, and I´ve no idea why.
Whole Project can be found here: https://github.com/FriedrichWessel/TestOBB
Important Code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class AssetStorage : MonoBehaviour {
public static AssetStorage Instance{
get;
set;
}
//public string[] PrefabNames;
public string prefab = "Penguin";
public string AssetBundleName;
public string message = "NONE";
//private Dictionary<string, AssetBundleRequest> requests = new Dictionary<string, AssetBundleRequest>();
private AssetBundleRequest request;
private string mainPath;
private string expPath;
private WWW www;
void Awake() {
DontDestroyOnLoad(gameObject);
if(Instance == null)
Instance = this;
}
void OnDestroy(){
//Instance = null;
Debug.LogError("Destroy");
}
// Use this for initialization
void Start () {
if(GooglePlayDownloader.RunningOnAndroid()){
expPath = GooglePlayDownloader.GetExpansionFilePath();
message = expPath;
mainPath = string.Empty;
if (expPath == null){
message = "External storage is not available!";
Debug.Log("External storage is not available!");
} else {
message = "Try get MainPath" ;
Debug.Log(message);
mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
Debug.Log("Main Path after first Fetch: " + mainPath);
message = "MainPath: " + mainPath;
}
if(mainPath == null){
message = "OBB not available - download!";
Debug.Log(message);
GooglePlayDownloader.FetchOBB();
mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
message = "OBB Fetch finished" + mainPath;
Debug.Log(message);
}
}
StartCoroutine(Load());
}
IEnumerator Load(){
string filePath = string.Empty;
if(GooglePlayDownloader.RunningOnAndroid()){
bool testResourceLoaded = false;
int count = 0;
while(!testResourceLoaded) {
mainPath = GooglePlayDownloader.GetMainOBBPath(expPath);
//Debug.Log("Main Path after Fetch: " + mainPath);
if(mainPath != null){
testResourceLoaded = true;
//Debug.Log("Found Main Path: " + mainPath);
break;
}
count++;
if(count > 60)
break;
yield return new WaitForSeconds(0.5f); //Let's not constantly check, but give a buffer time to the loading
}
if(!testResourceLoaded){
message = "Connectionion Timeout";
Debug.Log(message);
}
else{
message = "Loading Finished";
Debug.Log(message);
}
if(mainPath == null){
message = "MainFile still not found!";
Debug.Log(message);
}
filePath = "jar:file://" + mainPath;
filePath += "!/"+AssetBundleName+".unity3d";
} else {
filePath = "file://" + Application.dataPath;
filePath += "/"+AssetBundleName+".unity3d";
}
message = "FilePath: " + filePath;
Debug.Log(message);
www = WWW.LoadFromCacheOrDownload(filePath,0);
yield return www;
var bundle = www.assetBundle;
if(bundle == null)
Debug.Log("bundle == 0");
Instantiate(bundle.Load(prefab, typeof(GameObject)));
}
public string InstancePrefab(string name){
/*if(requests.ContainsKey(name)){
Instantiate(requests[name].asset);
return ("Finished loading: " + name);
} else
return ("Asset not found: " + name); */
//Instantiate(request.asset);
return ("Instance Finished: " + name ) ;
}
void OnGUI(){
GUI.Label(new Rect(10, 10, Screen.width-10, 20), message);
}
}
Thanks again !
Friedrich
P.S.: I get all the information from these links here:
Android Expansion Files: http://developer.android.com/guide/google/play/expansion-files.html#Testing
Usage of the OBB Plugin http://forum.unity3d.com/threads/150095-Split-APK-amp-Google-Play-OBB-Downloader-Question
Add License to the Google Play Account: http://developer.android.com/guide/google/play/licensing/index.html
I got the same problem... I cant find nothing in the log files. Have you found a solution?
Hey, I didnt test anything - because I switched to Download from my own Server. But somebody told me that there is a second GooglePlay Store Plugin in the AssetStore, which is for Authentification. I´m pretty sure that this is the thing I´m missing. Would be nice if you post here if it is so.
@FriedrichWessel, have you solved it? Your github version is functional?
not realy :) I worked around it by download Assetbundles from a custom server ( or S3 ). But the answer down from DerWaDoSo sounds reasonable.
I have managed to get it working, but I am not using Asset Bundle.
Answer by DerWoDaSo · Oct 30, 2012 at 12:38 PM
Looks like the Google Server need some time to update the files in some way. Yesterday I had a lot of problems (the one you described, but also others like "no file found" and similar), but checking it again today... everything just worked.
You don't need the "Google Play Application License Verification" plugin! This is for additional licensing checks and has nothing to do with the expansion file plugin (GooglePlay OBB Downloader), which provide their own LVL.
One problem I had, was the english app name, which has to be equal in the GooglePlay Dev Console and in the app itself. I haven't found this in the documentation (or just skipped it). ;)
Answer by arnodekostair · Dec 17, 2012 at 06:04 PM
I had the same problem. In my case I was forgetting the CHECK_LICENSE permission in the manifest file. Even if the application is free (and so no need to check the license), it seems that this permission is needed to download the expansion file.