Search Unity

Discussion UGS Initialization failed

Discussion in 'Unity Gaming Services General Discussion' started by lazydevx, Oct 24, 2022.

  1. lazydevx

    lazydevx

    Joined:
    Jan 3, 2017
    Posts:
    6
    UGS is working fine in editor but it is getting failed on Android device.

    exception:
    error message:

    This is the code I am using
    Code (CSharp):
    1. async void Awake()
    2.         {
    3.             try
    4.             {
    5.                 var options = new InitializationOptions()
    6.                     .SetEnvironmentName(environment)
    7. #if UNITY_ANDROID
    8.                     .SetGameId(androidGameId);
    9. #else
    10.                     .SetGameId(iOSGameId);
    11. #endif
    12.  
    13.                 await UnityServices.InitializeAsync(options);
    14.             }
    15.             catch (Exception exception)
    16.             {
    17.                 Debug.LogWarning("UGS Initialization failed: " + exception);
    18.             }
    19.         }
    20.     }
    Since UGS initialisation is getting failed I am not able to use Unity Mediation for ads.
    If I try to use unity mediation without UGS I am getting this error:

    In editor both UGS and Unity Mediation is working fine and I am able to get test ads.
    Unity Editor 2021.37f1
    Unity Mediation version 1.0.4
     
    Last edited: Oct 24, 2022
  2. U_AdrienPDB

    U_AdrienPDB

    Unity Technologies

    Joined:
    Aug 14, 2019
    Posts:
    8
    Hi, can you give us more information so we can help you out with your issue ?
    • The message from the "DependencyTreeSortFailedException" seems to be cut. Can you give us the whole message please ? Especially the json part including the "ordered" array.
    • I see in your error message that you got a "DependencyTreeComponentHashException". Was it thrown as is or was it logged with its error message ? Something like "Component with hash[<missing component hash>] does not exist!".
    • Can you specify your Android build configuration ? Mono or IL2CPP, API Compatibility level, Development build, ...
    • Can you share with us your project's manifest ? So we will know what packages you are using and we'll try to reproduce the issue on our side.
     
  3. tuntorius

    tuntorius

    Joined:
    Jul 31, 2013
    Posts:
    3
    @lazydevx are you, by chance, also using the RemoteConfig package?
    In my case, I was still using an obsolete initialization code. When I upgraded from RemoteConfig v2 to v3 some time ago, I didn't bother to update the init code.
    If it's the same with you, just update your code according to this page:
    https://docs.unity3d.com/Packages/com.unity.remote-config-runtime@3.0/manual/CodeIntegration.html

    @U_AdrienPDB I think the problem is that if RemoteConfig is used in obsolete mode, it replaces CorePackageInitializer from UnityServices with one that is missing some components - IAccessToken and IPlayerId, which are needed in the Mediation package.

    this is the entire json in my case:
    Code (JavaScript):
    1.  
    2. {
    3.       "ordered": [
    4.         {
    5.           "packageHash": -738560528,
    6.           "packageProvider": "CorePackageInitializer",
    7.           "packageDependencies": []
    8.         },
    9.         {
    10.           "packageHash": -738629072,
    11.           "packageProvider": "MediationServiceInitializer",
    12.           "packageDependencies": [
    13.             {
    14.               "dependencyHash": -1008441008,
    15.               "dependencyComponent": "IInstallationId",
    16.               "dependencyProvided": "true",
    17.               "dependencyOptional": "false"
    18.             },
    19.             {
    20.               "dependencyHash": -1008150256,
    21.               "dependencyComponent": "IProjectConfiguration",
    22.               "dependencyProvided": "true",
    23.               "dependencyOptional": "false"
    24.            },
    25.             {
    26.               "dependencyHash": -1008162224,
    27.               "dependencyComponent": "IMetricsFactory",
    28.               "dependencyProvided": "true",
    29.               "dependencyOptional": "false"
    30.             }
    31.           ]
    32.         }
    33.       ],
    34.       "packages": [
    35.         {
    36.           "packageHash": -738629072,
    37.           "packageProvider": "MediationServiceInitializer",
    38.           "packageDependencies": [
    39.             {
    40.               "dependencyHash": -1008441008,
    41.               "dependencyComponent": "IInstallationId",
    42.               "dependencyProvided": "true",
    43.               "dependencyOptional": "false"
    44.             },
    45.             {
    46.               "dependencyHash": -1008150256,
    47.               "dependencyComponent": "IProjectConfiguration",
    48.               "dependencyProvided": "true",
    49.               "dependencyOptional": "false"
    50.             },
    51.             {
    52.               "dependencyHash": -1008162224,
    53.               "dependencyComponent": "IMetricsFactory",
    54.               "dependencyProvided": "true",
    55.               "dependencyOptional": "false"
    56.             }
    57.           ]
    58.         },
    59.         {
    60.           "packageHash": -738650128,
    61.           "packageProvider": "Ua2CoreInitializeCallback",
    62.           "packageDependencies": [
    63.             {
    64.               "dependencyHash": -1008441008,
    65.               "dependencyComponent": "IInstallationId",
    66.               "dependencyProvided": "true",
    67.               "dependencyOptional": "false"
    68.             },
    69.             {
    70.               "dependencyHash": -1008506128,
    71.               "dependencyComponent": "IEnvironments",
    72.               "dependencyProvided": "true",
    73.               "dependencyOptional": "false"
    74.             },
    75.             {
    76.               "dependencyHash": -1008150256,
    77.               "dependencyComponent": "IProjectConfiguration",
    78.               "dependencyProvided": "true",
    79.               "dependencyOptional": "false"
    80.             },
    81.             {
    82.               "dependencyHash": -1008255856,
    83.               "dependencyComponent": "IPlayerId",
    84.               "dependencyProvided": "false",
    85.               "dependencyOptional": "false"
    86.             }
    87.           ]
    88.         },
    89.         {
    90.           "packageHash": -738560528,
    91.           "packageProvider": "CorePackageInitializer",
    92.           "packageDependencies": []
    93.         },
    94.         {
    95.           "packageHash": -738612944,
    96.           "packageProvider": "CorePackageInitializer",
    97.           "packageDependencies": [
    98.             {
    99.               "dependencyHash": -1008150256,
    100.               "dependencyComponent": "IProjectConfiguration",
    101.               "dependencyProvided": "true",
    102.               "dependencyOptional": "false"
    103.             },
    104.             {
    105.               "dependencyHash": -1008441008,
    106.               "dependencyComponent": "IInstallationId",
    107.               "dependencyProvided": "true",
    108.               "dependencyOptional": "false"
    109.             },
    110.             {
    111.               "dependencyHash": -1008350544,
    112.               "dependencyComponent": "IAccessToken",
    113.               "dependencyProvided": "false",
    114.               "dependencyOptional": "false"
    115.             },
    116.             {
    117.               "dependencyHash": -1008255856,
    118.               "dependencyComponent": "IPlayerId",
    119.               "dependencyProvided": "false",
    120.               "dependencyOptional": "false"
    121.             }
    122.           ]
    123.         },
    124.         {
    125.           "packageHash": -738526032,
    126.           "packageProvider": "IapCoreInitializeCallback",
    127.           "packageDependencies": [
    128.             {
    129.               "dependencyHash": -1008162224,
    130.               "dependencyComponent": "IMetricsFactory",
    131.               "dependencyProvided": "true",
    132.               "dependencyOptional": "false"
    133.             },
    134.             {
    135.               "dependencyHash": -1008341040,
    136.               "dependencyComponent": "IDiagnosticsFactory",
    137.               "dependencyProvided": "true",
    138.               "dependencyOptional": "false"
    139.             }
    140.           ]
    141.         }
    142.       ],
    143.       "components": [
    144.         {
    145.           "componentHash": -1008441008,
    146.           "component": "IInstallationId",
    147.           "componentPackageHash": -738560528,
    148.           "componentPackage": "CorePackageInitializer"
    149.         },
    150.         {
    151.           "componentHash": -1008150256,
    152.           "component": "IProjectConfiguration",
    153.           "componentPackageHash": -738560528,
    154.           "componentPackage": "CorePackageInitializer"
    155.         },
    156.         {
    157.           "componentHash": -1008162224,
    158.           "component": "IMetricsFactory",
    159.           "componentPackageHash": -738560528,
    160.           "componentPackage": "CorePackageInitializer"
    161.         },
    162.         {
    163.           "componentHash": -1008506128,
    164.           "component": "IEnvironments",
    165.           "componentPackageHash": -738560528,
    166.           "componentPackage": "CorePackageInitializer"
    167.         },
    168.         {
    169.           "componentHash": -1008255856,
    170.           "component": "IPlayerId",
    171.           "componentPackageHash": 0,
    172.           "componentPackage": "null"
    173.         },
    174.         {
    175.           "componentHash": -1008350544,
    176.           "component": "IAccessToken",
    177.           "componentPackageHash": 0,
    178.           "componentPackage": "null"
    179.         },
    180.         {
    181.           "componentHash": -1008341040,
    182.           "component": "IDiagnosticsFactory",
    183.           "componentPackageHash": -738560528,
    184.           "componentPackage": "CorePackageInitializer"
    185.         }
    186.       ]
    187.     }
    188.  
     
  4. lazydevx

    lazydevx

    Joined:
    Jan 3, 2017
    Posts:
    6
    @tuntorius Thanks a lot, issue got solved after updating Remote config code from v2 to v3 and calling the remote config fetch after UGS initialisation is completed.

    @U_AdrienPDB It seems UGS init was failed because I was calling v2 remote config code before initialising the UGS.