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\[email protected]\Runtime\AddressablesImpl.cs:225)
E/Unity (16787): UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception) (at E:\mahmoud baghani\Payiz\Library\PackageCache\[email protected]\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\[email protected]\Runtime\AddressablesImpl.cs:225)
E/Unity (16787): UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception) (at E:\mahmoud baghani\Payiz\Library\PackageCache\[email protected]\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\[email protected]\Runtime\AddressablesImpl.cs:225)
E/Unity (16787): UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception) (at E:\mahmoud baghani\Payiz\Library\PackageCache\[email protected]\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?