Search Unity

Loading Addressable in IL2CPP build causes UnknownResourceProviderException

Discussion in 'Addressables' started by yuch3n, Mar 7, 2019.

  1. yuch3n

    yuch3n

    Joined:
    Sep 26, 2018
    Posts:
    26
    This is my first time setting up Addressables for our game, so please bear with me.

    I managed to get a test Sprite to load and display from our remote HTTP content server on an Android device using Mono compilation, but when I use IL2CPP, the Sprite will not load.

    Here is my code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.ResourceManagement.AsyncOperations;
    5. using UnityEngine.UI;
    6. using UnityEngine.AddressableAssets;
    7. public class AddressableTestController : MonoBehaviour
    8. {
    9.     public Image image;
    10.     void Start()
    11.     {
    12.         Debug.LogError("Attempting to load the WaterDoggo asset");
    13.         IAsyncOperation<Sprite> x = Addressables.LoadAsset<Sprite>("WaterDoggo");
    14.         x.Completed += onLoadDone;
    15.     }
    16.  
    17.     private void onLoadDone(IAsyncOperation<Sprite> obj) {
    18.         Debug.LogError("Success loading WaterDoggo");
    19.         image.sprite = obj.Result;
    20.     }
    21. }
    22.  
    Error logs show this: (I've removed some of the unimportant lines)

    Code (CSharp):
    1. 03-07 13:15:45.454 : Attempting to load the WaterDoggo asset
    2. ...
    3. 03-07 13:15:45.454 : AddressableTestController:Start()
    4. ...
    5. 03-07 13:15:46.362 : UnknownResourceProviderException encountered in operation UnityEngine.ResourceManagement.AsyncOperations.CompletedOperation`1[UnityEngine.Sprite], result='', status='None', valid=True, location=..
    6. ...
    7. 03-07 13:15:46.367 : UnknownResourceProviderException: Exception of type 'UnityEngine.ResourceManagement.Util.UnknownResourceProviderException' was thrown., ProviderId=UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider_0_0, Location=Assets/SplendidAssets/AddressableTest/waterdog.jpg
    8.  
    The image didn't actually display like in the Mono build after the UnknownResourceProviderException was thrown. The only thread that I could find that seemed to be related was this one: https://forum.unity.com/threads/il2cpp-webgl-stripping-prevention.544030/
    But my Sprite doesn't have any dependencies or classes on it that could be stripped. So it seems to be a different problem? The exception itself doesn't bring up any relevant results either. Why might il2cpp cause this issue? It's the only thing that is different between my working and non-working builds.
     
  2. yuch3n

    yuch3n

    Joined:
    Sep 26, 2018
    Posts:
    26
    Nevermind, right on the day I posted this, 0.6.7-preview was released, and it fixed my issue! The sprite now loads on il2cpp builds. Turns out it was the il2cpp stripping problem after all, as that's what the update fixed.
     
    unity_bill and MNNoxMortem like this.