1
\$\begingroup\$

I've incorporated Unity's addressable package into my project, but the issue I have is the addressables do not get loaded when I'm testing on android. The problem persists for all my addressable that I have, but in this special case, I want to load map texture (which is a huge texture in term of size) when the player opens the map, and unload it when he/she close it.

here is the InitializeMap coroutine which makes sure all the core elements for map are available before I continue the flow:

 public IEnumerator InitializeMapReferences()
    {
       // find map reference and Initialize it
        _map = GameObject.FindGameObjectWithTag("MapCamera").GetComponent<MapManager>();
        yield return StartCoroutine(_map.Initialize());
    }

the map initialize coroutine is as follows:

public IEnumerator Initialize()
    {
        // load map texture instance
        var mapTextureInstanceLoad = m_mapTextureInstance.InstantiateAsync();
        yield return mapTextureInstanceLoad;
        m_mapTextureGameobject = mapTextureInstanceLoad.Result;
    }

here is my addressableAssetSettings Here is the log from adb's logcat:

    E/Unity   (16787): Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[UnityEngine.GameObject], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=035a9d5a8d41d8b42a738cf8b98c7781
E/Unity   (16787): UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
E/Unity   (16787): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
E/Unity   (16787): UnityEngine.Logger:LogFormat(LogType, String, Object[])
E/Unity   (16787): UnityEngine.Debug:LogErrorFormat(String, Object[])
E/Unity   (16787): UnityEngine.AddressableAssets.AddressablesImpl:LogException(AsyncOperationHandle, Exception) (at E:\mahmoud baghani\Payiz\Library\PackageCache\com.unity.addressables@1.5.0\Runtime\AddressablesImpl.cs:225)
E/Unity   (16787): UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception) (at E:\mahmoud baghani\Payiz\Library\PackageCache\com.unity.addressables@1.5.0\Runtime\ResourceManager\AsyncOperations\AsyncOperationBase.cs:286)
E/Unity   (16787): UnityEngine.ResourceManagement.AsyncO
E/Unity   (16787): Exception encountered in operation UnityEngine.AddressableAssets.Initialization.InitializationOperation, result='', status='Succeeded' - Chain<GameObject>: ChainOperation of Type: UnityEngine.GameObject failed because dependent operation failed
E/Unity   (16787): Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=035a9d5a8d41d8b42a738cf8b98c7781
E/Unity   (16787): UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
E/Unity   (16787): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
E/Unity   (16787): UnityEngine.Logger:LogFormat(LogType, String, Object[])
E/Unity   (16787): UnityEngine.Debug:LogErrorFormat(String, Object[])
E/Unity   (16787): UnityEngine.AddressableAssets.AddressablesImpl:LogException(AsyncOperationHandle, Exception) (at E:\mahmoud baghani\Payiz\Library\PackageCache\com.unity.addressables@1.5.0\Runtime\AddressablesImpl.cs:225)
E/Unity   (16787): UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception) (at E:\mahmoud baghani\Payiz\Library\PackageCache\com.unity.addressables@1.5.0\Runtime\Resourc
E/Unity   (16787): Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[UnityEngine.GameObject], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=adc44a52236cf704fab2efdb10c1c9e3
E/Unity   (16787): UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
E/Unity   (16787): UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
E/Unity   (16787): UnityEngine.Logger:LogFormat(LogType, String, Object[])
E/Unity   (16787): UnityEngine.Debug:LogErrorFormat(String, Object[])
E/Unity   (16787): UnityEngine.AddressableAssets.AddressablesImpl:LogException(AsyncOperationHandle, Exception) (at E:\mahmoud baghani\Payiz\Library\PackageCache\com.unity.addressables@1.5.0\Runtime\AddressablesImpl.cs:225)
E/Unity   (16787): UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception) (at E:\mahmoud baghani\Payiz\Library\PackageCache\com.unity.addressables@1.5.0\Runtime\ResourceManager\AsyncOperations\AsyncOperationBase.cs:286)
E/Unity   (16787): UnityEngine.ResourceManagement.AsyncO
E/Unity   (16787): NullReferenceException: Object reference not set to an instance of an object
E/Unity   (16787):   at MapManager+<Initialize>d__53.MoveNext () [0x00101] in E:\mahmoud baghani\Payiz\Assets\Code\MapManager.cs:125
E/Unity   (16787):   at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00020] in /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17
E/Unity   (16787):

As you can see, this exceptions results in null references (like the one I've included inside the log I have posted) and make the game unplayable as I am relying on addressables to load/unload some of my core stuff like map textures or big render textures. The problem does not reveal itself in the editor. I've tried cleaning and rebuilding the addressables with no success. How should I go about solving this problem?

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Please show us enough detail of your scripts/scene setup that we can reproduce the problem in a new, empty project. Once we can see the problem live on our own devices, this will allow us to test solutions to be sure they really work. \$\endgroup\$ – DMGregory Feb 9 '20 at 20:15
  • \$\begingroup\$ @DMGregory thanks for the reply. I've updated my post. \$\endgroup\$ – Mahdad Baghani Feb 10 '20 at 8:28
  • 2
    \$\begingroup\$ You should post your fix as an answer to your own question, and then accept it as an answer. \$\endgroup\$ – Natalo77 Feb 10 '20 at 11:17
  • 1
    \$\begingroup\$ @Natalo77 thanks for pointing me in the right direction \$\endgroup\$ – Mahdad Baghani Feb 10 '20 at 12:47
4
\$\begingroup\$

UPDATE:

I managed to fix the problem. Here is how I did it: The build script that is recommended by unity for builds is Packed mode. I had several asset groups, but the asset group that I used for the map textures, lacked a scheme. Adding a "content packing loading" scheme to my map asset group, and then "Build/new build/default build scrip" from addressables groups window solved the problem.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.