We use this code to load a remote catalog:
try {
AsyncOperationHandle<IResourceLocator> operation = Addressables.LoadContentCatalogAsync(url);
await operation.Task;
Debug.Log("State of loading Addressables remote catalog: " + operation.Status);
} catch (System.Exception e) {
Debug.LogWarning("LoadContentCatalogAsync failed with exception:\n\n" + e);
}
It works fine on Windows. However, when it runs on Android, it crashes with this exception:
System.NullReferenceException: Object reference not set to an instance of an object
at UnityEngine.ResourceManagement.AsyncOperations.InitalizationObjectsOperation.Execute () [0x00014] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\Initialization\InitializationObjectsOperation.cs:29
at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase1[TObject].InvokeExecute () [0x00001] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\ResourceManager\AsyncOperations\AsyncOperationBase.cs:413 at UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject].Start (UnityEngine.ResourceManagement.ResourceManager rm, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency, DelegateList1[T] updateCallbacks) [0x00076] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\ResourceManager\AsyncOperations\AsyncOperationBase.cs:407 at UnityEngine.ResourceManagement.ResourceManager.StartOperation[TObject] (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase
1[TObject] operation, UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle dependency) [0x00001] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\ResourceManager\ResourceManager.cs:409
at UnityEngine.AddressableAssets.Initialization.InitializationOperation.CreateInitializationOperation (UnityEngine.AddressableAssets.AddressablesImpl aa, System.String playerSettingsLocation, System.String providerSuffix) [0x000c5] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\Initialization\InitializationOperation.cs:59
at UnityEngine.AddressableAssets.AddressablesImpl.InitializeAsync (System.String runtimeDataPath, System.String providerSuffix, System.Boolean autoReleaseHandle) [0x00110] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\AddressablesImpl.cs:396
at UnityEngine.AddressableAssets.AddressablesImpl.InitializeAsync () [0x00001] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\AddressablesImpl.cs:405
at UnityEngine.AddressableAssets.AddressablesImpl.get_ChainOperation () [0x0000e] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\AddressablesImpl.cs:128
at UnityEngine.AddressableAssets.AddressablesImpl.LoadContentCatalogAsync (System.String catalogPath, System.Boolean autoReleaseHandle, System.String providerSuffix) [0x00051] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\AddressablesImpl.cs:428
at UnityEngine.AddressableAssets.Addressables.LoadContentCatalogAsync (System.String catalogPath, System.String providerSuffix) [0x00001] in C:\project\Library\PackageCache\com.unity.addressables@1.10.0\Runtime\Addressables.cs:296
at AddressablesInitializer+d__7.MoveNext () [0x00035] in C:\project\Assets\Main\Scripts\Common\Application Initializer\AddressablesInitializer.cs:27
We confirmed that the URL for the catalog is accessible and it opens correctly in an Android browser, so this seems like a bug…?
The crash happens here, in InitalizationObjectsOperation.cs due to the result of the operation (rtd) being null:
The operation seems to be started from here, in InitializationOperation.cs:
Any ideas?
This is using Unity 2019.4.1f1 and Addressables 1.10.
We have our Addressables in a separate project, so that we can keep using the same Unity version and keep retro-compatibility with the app, even if users use an older version. Is this a problem in any way? It means that there are no Addressable groups in the app project itself. Again, Windows builds work fine with the same code.
Thanks!
Seems like it’s fixed in either version 1.11 or 1.12. I had to forcefully work around the bugs/breaking changes in those versions to reach this conclusion.
Hi CanisLupus, how you work around it? I have the same issue. my code here:
AsyncOperationHandle<IResourceLocator> loadContentCatalogAsync = Addressables.LoadContentCatalogAsync(
@catalogPath);
loadContentCatalogAsync.Completed += OnCompleted;
}
private void OnCompleted(AsyncOperationHandle<IResourceLocator> obj)
{
IResourceLocator resourceLocator = obj.Result;
Debug.Log(obj.Status);
if (obj.Status.ToString() == "Succeeded")
{
InitAndWaitUntilLocLoaded();
}
else
{
canvas.transform.Find("ErrorMsg").GetComponent<Text>().text = "File not found in " + catalogPath;
}
I can get the Status “Succeeded” in Unity Editor, but get “Failed” when run from Android phone
Hi @zhouhong , what I meant was that the problem I originally had was fixed in version 1.11 or 1.12, but those versions had other problems at the time, around which I had to work before being able to confirm that they fixed it.
I don’t know about your specific case but the problem shouldn’t happen in current versions! Well, unless there was a regression. NOTE: I haven’t used Addressables in a while.