Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Asset Bundles on Android 9

Discussion in 'Editor & General Support' started by Pulse-Tech, Dec 19, 2018.

  1. Pulse-Tech

    Pulse-Tech

    Joined:
    Sep 20, 2018
    Posts:
    3
    Asset bundles in Android 9 can’t be downloaded, it displays an ERROR warning “unknown error” when trying to download from the server.

    We have an asset bundle of an entire scene hosted on a webserver ready to be downloaded, save it on a mobile device and use it from that memory allocation.

    We implemented a script, which is responsible of the whole process. The download process is made though Unity’s WWW Class. We also tried to achieve that using the “UnityWebRequest” Class, with the same ERROR result.

    With this arrangement of bytes, we proceed to save it to a file on the cell phone, using the “File.WriteAllBytes ()” Method.

    Then use the “AssetBundleCreateRequest “ Class and the “LoadFromFileAsync()” Method to get the Scene through the “GetAllScenePaths()” Method.

    Every time we do all this process in any Android version before 9, there is no problem. It downloads, save and show the required Scene and the next time we want to access the same Scene it starts from the cell phone and not from the server.

    But when wanting to download in a version of Android 9 and up, the code runs to the part where we search if there was an error in the download or if it has finished downloading, at this code point:

    while (!www.isDone && string.IsNullOrEmpty(www.error)){}

    And jump straight to this point on the code:

    if (!string.IsNullOrEmpty(www.error)) { Debug.Log(www.error) }

    And when we want to print the error to know what happened, always print an “unknown error”.

    In the android manifest you have the permissions granted in the following way:

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="replace"/>


    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />


    <meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />

    You have an option to share a screen capture through the asset "Native Share" of the Asset Store, and it does it without any problem, so we think that in fact, we already have the permissions to read and write on the cell phone.

    We are using Unity 2018.2.1f1 with the native 7.2.24 Vuforia support for the Bundles creation which is used for the AssetBundle Browser.
     
  2. unity_HIcx8RNLJW3Kvg

    unity_HIcx8RNLJW3Kvg

    Joined:
    Apr 16, 2019
    Posts:
    1
    I have same error.Did you find any solution
     
  3. Pulse-Tech

    Pulse-Tech

    Joined:
    Sep 20, 2018
    Posts:
    3
    Unfortunately the only solution is migrate all the project to Unity 2018.2.1. Time consuming but effective.
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    2,307
    Do you use HTTP or HTTPS when downloading from server?
    Android 9 requires HTTPS by default, you have to enable HTTP in the manifest.