0

I'm getting the following exception when I build my game for android

WWW download had an error: java.lang.IllegalArgumentException: uri == null

Now I haven o idea why this is happening because it works fine in the editor. Here is the relevant code :

assetLoader.BundleURL = "ftp://user:pass@81.161.248.122/Unity-Uri/AssetBundles/seasonalcontent/christmas";
            assetLoader.version = 1;
            assetLoader.StartDownload();

and the actual download code :

IEnumerator DownloadAndCache()
    {
        // Wait for the Caching system to be ready
        while (!Caching.ready)
            yield return null;

        // Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
        using (WWW www = WWW.LoadFromCacheOrDownload(BundleURL, version))
        {
            yield return www;
            if (www.error != null)
                throw new Exception("WWW download had an error:" + www.error);
            AssetBundle bundle = www.assetBundle;
            SeasonManager.assets = bundle.LoadAllAssets();
            Debug.Log("Stop");
            OnContentLoaded();
        } // memory is freed from the web stream (www.Dispose() gets called implicitly)
    }

Edit: I got this from the documentation : ftp:// protocol support is limited to anonymous downloads only. Is ftp not supported on android ?

Edit 2: As suggest in the comments I tried this and it results in a Login failed error :

 IEnumerator makeRequest()
    {
        string authorization = authenticate("username", "pass");
        string url = "ftp://ipgoeshere";


        UnityWebRequest www = UnityWebRequest.Get(url);
        www.SetRequestHeader("AUTHORIZATION", authorization);

        yield return www.Send();
        if (www.isError)
        {
            Debug.Log(www.error);
        }
        else
        {
            AssetBundle bundle = ((DownloadHandlerAssetBundle)www.downloadHandler).assetBundle;
            SeasonManager.assets = bundle.LoadAllAssets();
        }
    }
string authenticate(string username, string password)
    {
        string auth = username + ":" + password;
        auth = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(auth));
        auth = "Basic " + auth;
        return auth;
    }

To clarify I've made sure that the username password and the server address are correct. I have simply removed them from the code here for obvious reasons.

Uri Popov
  • 2,127
  • 2
  • 25
  • 43
  • 1
    Looking at the url, this looks like an authentication problem. Please take a look at [this](http://stackoverflow.com/a/39489237/3785314) and tell me if that solves your problem. – Programmer Dec 10 '16 at 18:09
  • Did this solve your problem? I want to know for future similar question. – Programmer Dec 11 '16 at 15:53
  • @Programmer Hey I just got into work. I'm going to set up a ftp server with anonymous download and see if that works. Then I will try your solution. – Uri Popov Dec 12 '16 at 08:55
  • I tried the solution from the link but I get a Login failed error and sadly I have no idea how to address it. – Uri Popov Dec 12 '16 at 09:54
  • I suggest you edit your question and post the new code you made that is throwing that error. I will then tell you if that's what I expected. – Programmer Dec 12 '16 at 10:17

0 Answers0