Search Unity

UnityWebRequest and streaming assets - JAR file is not supported (Android)

Discussion in 'Scripting' started by Uber6, Aug 16, 2016.

  1. Uber6

    Uber6

    Joined:
    Sep 30, 2013
    Posts:
    25
    So today I wanted to change WWWs to UnityWebRequest for downloading asset bundles. However I 'download' some of my bundles from the streaming assets which works fine with WWW but does not with UnityWebRequest, it gives me an error:

    A URL Connection to a Java ARchive (JAR) file or an entry in a JAR file is not supported

    and

    Failed downloading bundle bundlename from jar:file:/data/app/game.apk/assets/asset: Unsupported Protocol

    I can't find anything about streaming assets and UnityWebRequest in documentation? Is this possible at the moment? Should I go back to WWWs? I could use both WWWs and UnityWebRequests but I would prefer not to because WWWs are supposed to be deprecated at some point.

    I am using Unity 5.3.6f1 (can't update to 5.4.0f3 just yet). Maybe that has been solved in 5.4.0f3?
     
  2. Uber6

    Uber6

    Joined:
    Sep 30, 2013
    Posts:
    25
    Selfish bump cause I am getting desperate : /
     
  3. KJoanette

    KJoanette

    Joined:
    Jun 8, 2013
    Posts:
    59
    More bumps!
     
  4. cdytoby

    cdytoby

    Joined:
    Nov 19, 2014
    Posts:
    181
    I just encountered the same issue.
    I really don't want to use www since UnityWebRequest have custom download handler so that I can write anything on my own way, including FinishedEvent, directly save file to local, even load file from local path!

    But this issue seems to be related to Android webrequest, it's probably not Unity's fault.

    So I think, either using www, or stop using StreamingAssets, wait for Unity create a new similar class to load file from streamingassets, because in the current status, streaming assets are not very useful.
     
  5. molx88

    molx88

    Joined:
    Apr 6, 2015
    Posts:
    6
    I've been doing some research on Asset Bundles, and came across this snippet from a best practices post from unity about this exact issue:

    Android Developers: On Android, Application.streamingAssetsPath will point to a compressed .jar file, even if the AssetBundles are compressed. In this case, WWW.LoadFromCacheOrDownload must be used to load each AssetBundle. It is also possible to write custom code to decompress the .jar file and extract the AssetBundle to a readable location on local storage.
    I'll be testing Asset Bundles today and will see if I run into any issues with Android, using Unity 5.4 (the issue you're running into is reported to have been fixed in 5.4)
     
  6. ADoby

    ADoby

    Joined:
    Dec 10, 2012
    Posts:
    21
  7. jemonsuarez

    jemonsuarez

    Joined:
    Sep 24, 2012
    Posts:
    151
    I'm into the same problem and UnityWebRequest looks far from being complete.
    The other issue I'm facing is the decompression of mp3 and ogg audio clips, and I'm currently implementing my own custom classes to do this task.
    Maybe there is a way to decompress .jar files easily in Android.
     
  8. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Why did you resurect this ancient thread about issues that have been fixed long since?
    UWR supports reading streaming assets since 2017.1 IIRC.
    And what's the problem about mp3/ogg? UnityWebRequestMultimedia.GetAudioClip() should be able to do that.
     
  9. cdytoby

    cdytoby

    Joined:
    Nov 19, 2014
    Posts:
    181
    Unity staff? Great, I want to ask something related, I'm using almost the latest 2017.4.

    1. MP3 decoding license is not a problem some time ago, can we have GetAudioClip() work with mp3 file on both windows and macos?
    2. From what I tested some time ago (I don't know if that is still the case), if I load the mp3 audio file from local drive on android using UnityWebRequest, the property AudioClipLoadType is never streaming, is this normal?
     
  10. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    That API can load any format that is supported by audio subsystem on a given platform, see:
    https://docs.unity3d.com/Manual/class-AudioClip.html

    Yes, UWR will not stream audio from file on disk it always works the same regardless of whether audio comes from network or from local file.
     
  11. cdytoby

    cdytoby

    Joined:
    Nov 19, 2014
    Posts:
    181
    Sorry I didn't ask the right question, I mean in RUNTIME, mp3 files in the local disc, "persistantDataPath" to be specific, using UnityWebRequest to load them. As far as I know, at least in 2017.4, mp3 files can't be load in runtime on Windows and Mac using UWR. Will that be changed in the future?
     
  12. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Please, ask this question in the Audio&Video section. This is where the audio guys are hanging out.
    UWR just reads the raw compressed bytes and pass them to audio subsystem, format support and future plans are best known by audio guys.