Search Unity

Question KeyNotFoundException: There is no component `IAccessToken` registered.

Discussion in 'Unity Remote Config' started by mhardy, Nov 3, 2021.

  1. mhardy

    mhardy

    Joined:
    Apr 3, 2011
    Posts:
    48
    I had RemoteConfig working in Unity 2019.4.29f1. We decided to upgrade to 2021.2 and now RemoteConfig no longer works.

    I can Push & Pull from the Remote Config window in the editor, but when I hit Play my RemoteConfigManager throws an exception when it tries to fetch.

    I can't find anything about a Unity IAccessToken component.

    Any idea what this is?


    KeyNotFoundException: There is no component `IAccessToken` registered. Are you missing a package?
    Unity.Services.Core.Internal.ComponentRegistry.GetServiceComponent[TComponent] () (at Library/PackageCache/com.unity.services.core@1.1.0-pre.10/Runtime/Core.Internal/Registry/ComponentRegistry/ComponentRegistry.cs:50)
    Unity.Services.Core.Internal.CoreRegistry.GetServiceComponent[TComponent] () (at Library/PackageCache/com.unity.services.core@1.1.0-pre.10/Runtime/Core.Internal/Registry/CoreRegistry.cs:92)
    Unity.RemoteConfig.ConfigManager.get_ConfigManagerImpl () (at Library/PackageCache/com.unity.remote-config-runtime@3.0.0-pre.10/Runtime/ConfigManager.cs:36)
    Unity.RemoteConfig.ConfigManager.add_FetchCompleted (System.Action`1[T] value) (at Library/PackageCache/com.unity.remote-config-runtime@3.0.0-pre.10/Runtime/ConfigManager.cs:81)
    RemoteConfigManager.FetchRemoteConfig () (at Assets/_Game/Code/GameStructure/RemoteConfigManager.cs:52)
    RemoteConfigManager.Awake () (at Assets/_Game/Code/GameStructure/RemoteConfigManager.cs:19)
     
    SebT_Unity likes this.
  2. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Hi mhardy,

    Thanks for posting.

    Could you share what version of the remote config package you are using?
    You could find this by going to WINDOW > PACKAGE MANAGER
    Search packages within your project and you will see a version number.

    Would it also be possible to share your Organization Name so I can do some further investigation on your org? You can share that information in a direct message by clicking on my name and starting a conversation.

    Thanks for the additional details.
     
  3. mhardy

    mhardy

    Joined:
    Apr 3, 2011
    Posts:
    48
    I was using "3.0.0-pre.3". I just tried "3.0.0-pre.4" but same problem so I tried the release version of 2.1.2 and it fixed it!

    It also appears to have fixed "A Native Collection has not been disposed, resulting in a memory leak". Which looks like it might have been this. But rolling back to 2.1.2 fixed that as well.
     
    SebT_Unity likes this.
  4. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Hi mhardy,

    Thanks for sharing your workaround and all your help in direct messages for confirming that the solution below works.

    For anyone who wants to continue with version 3.0.0 and up please continue reading below.

    For the new version of Remote config you would need to integrate the authentication service.
    Here is additional documentation for the code integration in 3.0.0 and up

    A quick extract of what would need to be done.
    Import the package within your manifest.json located under Packages/manifest.json
    Code (CSharp):
    1.  
    2. using Unity.Services.Core;
    3. using Unity.RemoteConfig;
    4. using Unity.Services.Authentication;
    5.  
    Followed by initializing anonymous user
    Code (CSharp):
    1.  
    2. async void Start () {
    3.         await UnityServices.InitializeAsync();
    4.         if (!AuthenticationService.Instance.IsSignedIn)
    5.         {
    6.             await AuthenticationService.Instance.SignInAnonymouslyAsync();
    7.         }
    8. }
    9.  
    Best,
    Sebastiano
     
    unity_Ctri, tagh and vd_unity like this.
  5. dtootill

    dtootill

    Joined:
    Oct 9, 2020
    Posts:
    29
    I am seeing this and similar messages since upgrading to Unity 2021.3.21f1. I have Remote Config 3.3.1 and Authentication 2.4.0 installed, and have the SignInAnonymouslyAsync() code cited above running. However, I'm getting two instances of the error:

    Rethrow as AggregateException: One or more errors occurred. (Could not resolve type with token 01000043 from typeref (expected class 'Newtonsoft.Json.Utilities.AotHelper' in assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed')) (There is no component `IActionScheduler` registered. Are you missing a package?) (There is no component `ICloudProjectId` registered. Are you missing a package?) (There is no component `IProjectConfiguration` registered. Are you missing a package?) (There is no component `IDiagnosticsFactory` registered. Are you missing a package?)

    Also:
    • I'm not using Newtonsoft.Json.Utilities (I use Litjson)
    • If I start Unity with debugging active, I get breaks on a dozen instances of a missing component, with repeated instances of the four cited in the message ( IActionScheduler ICloudProjectId IProjectConfiguration IDiagnosticsFactory) and also IEnvironments
    • The errors don't have any obvious operational consequences, as Remote Config is working properly
    What is causing this and what can I do to eliminate the errors?
     
  6. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Hi there,

    Thanks for reporting this.
    Can you please navigate to the root folder of your project,
    Project folder> Packages > packages-lock.json
    Locate Remote-Config-Runtime
    upload_2023-3-20_12-53-11.png

    Please let me know the core version you are using
    Look forward to your response.
     
  7. dtootill

    dtootill

    Joined:
    Oct 9, 2020
    Posts:
    29
    Thanks for looking at this! Here's the relevant section of packages-lock.json:

    "com.unity.remote-config": {
    "version": "3.3.1",
    "depth": 0,
    "source": "registry",
    "dependencies": {
    "com.unity.nuget.newtonsoft-json": "3.0.2",
    "com.unity.modules.unitywebrequest": "1.0.0",
    "com.unity.remote-config-runtime": "3.1.3"
    },
    "url": "https://packages.unity.com"
    },
    "com.unity.remote-config-runtime": {
    "version": "3.1.3",
    "depth": 1,
    "source": "registry",
    "dependencies": {
    "com.unity.nuget.newtonsoft-json": "3.0.2",
    "com.unity.modules.unitywebrequest": "1.0.0",
    "com.unity.modules.unityanalytics": "1.0.0",
    "com.unity.services.core": "1.4.0",
    "com.unity.services.authentication": "2.0.0"
    },
    "url": "https://packages.unity.com"
    },​

    As you can see, I am using remote-config-runtime 3.1.3 and com.unity.services.core 1.4.0

    The only significant difference between my file and yours is that mine cites remote-config version 3.3.1, while yours specifies 3.2.2. Would it be worth trying a downgrade?

    Finally, I was incorrect above when I said there were no operation consequences; in fact, Remote Config is not working at all. Also, it's clear from this that the reference to newtonsoft-json comes from Remote Config itself.
     
    Last edited: Mar 21, 2023
  8. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Hi again,
    Could you try the following please let me know your results:

    Project folder> Packages > manifest.json
    Open it the file and add this to the dependencies
        "com.unity.services.core": "1.8.1",

    upload_2023-3-22_9-28-6.png

    This will pull the latest CORE and remote config and other services will begin to use this core instead.
    Please let me know if it solves the problem. I look forward to your response.

    Seb
     
  9. dtootill

    dtootill

    Joined:
    Oct 9, 2020
    Posts:
    29
    Thanks! That did it - Remote Config is working now.

    FYI, my manifest.json looks quite a bit different from yours. It doesn't have collab-proxy or feature.2d (or services.core). It does have ide.visualstudio and I inserted the line for services.core before that:

    {
    "dependencies": {
    "com.ecasillas.missingrefsfinder": "https://github.com/edcasillas/unity-missing-references-finder.git",
    "com.srejonkhan.another-file-browser": "https://github.com/SrejonKhan/AnotherFileBrowser.git",
    "com.unity.2d.sprite": "1.0.0",
    "com.unity.ads": "4.4.1",
    "com.unity.services.core": "1.8.1",
    "com.unity.ide.visualstudio": "2.0.17",
    "com.unity.ide.vscode": "1.2.5",
    "com.unity.mobile.notifications": "2.1.1",
    "com.unity.purchasing": "4.6.0",
    "com.unity.purchasing.udp": "2.2.5",
    "com.unity.remote-config": "3.3.1",​
     
    SebT_Unity likes this.
  10. dtootill

    dtootill

    Joined:
    Oct 9, 2020
    Posts:
    29
    Unfortunately, I'm not out of the woods yet. Making the change does resolve the issue, but it comes back after a while. Restarting Unity fixes the problem again, but only temporarily. I'm wondering if there's something that's bringing back the older services.core. Should I change every reference in packages-lock.json?
     
  11. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    Hi dtootill,
    Modifying the package.lock will be overridden when reloading Unity.

    Could you try the following:
    add this after the dependencies closing bracket:
      ,"resolutionStrategy": "highestMinor"


    bear in mind this will force all packages to use the latest versions and may cause you other issues so please test and make sure you don't run into other problems.
     
    Last edited: Mar 23, 2023
  12. dtootill

    dtootill

    Joined:
    Oct 9, 2020
    Posts:
    29
    I've been running with

    "resolutionStrategy": "highestMinor"

    for a week now, with no recurrences of the original issue and no new ones, so it looks like the problem's fixed. Thanks for your help!
     
    SebT_Unity likes this.