Search Unity

Resolved Unity IAP initialization stopped working

Discussion in 'Unity IAP' started by GeorgeMincila, Feb 11, 2023.

Thread Status:
Not open for further replies.
  1. GeorgeMincila

    GeorgeMincila

    Joined:
    Feb 28, 2016
    Posts:
    36
    The app is live and working. I implemented some updates not related to purchasing. When finishing up to submit to the Play Store & App Store I noticed a bug. It turns out the
    UnityPurchasing.Initialize(this, builder);
    is not executing anymore. Instead I see this error below happening.
    Code (CSharp):
    1. 2023-02-11 14:54:44.846 29515-29625/? E/Unity: ServicesInitializationException: The Analytics service has not been initialized. Please initialize Unity Services.
    2.       at Unity.Services.Analytics.AnalyticsService.get_Instance () [0x00000] in <00000000000000000000000000000000>:0
    3.       at UnityEngine.Purchasing.UnityPurchasing.Initialize (UnityEngine.Purchasing.IStoreListener listener, UnityEngine.Purchasing.ConfigurationBuilder builder) [0x00000] in <00000000000000000000000000000000>:0
    4.       at StoreController.InitializePurchasing () [0x00000] in <00000000000000000000000000000000>:0
    5.       at MainNavController.Start () [0x00000] in <00000000000000000000000000000000>:0
    Any ideas why that is happening?
     
    planetfactory and vadim_unity978 like this.
  2. vadim_unity978

    vadim_unity978

    Joined:
    Feb 11, 2020
    Posts:
    2
    https://docs.unity3d.com/Packages/c...al/UnityIAPInitializeUnityGamingServices.html
    I solve this - set checkbox Automatically initialize Unity Gaming Services
    Unity Doc- https://docs.unity3d.com/Packages/c...al/UnityIAPInitializeUnityGamingServices.html
     
  3. GeorgeMincila

    GeorgeMincila

    Joined:
    Feb 28, 2016
    Posts:
    36
    I saw that page myself. However, I do not have that anywhere. Should be in the IAP catalog? I am not using it. And even so, I open it, the UI does not have those two items with checkboxes at the beginning.
     
  4. planetfactory

    planetfactory

    Joined:
    May 18, 2016
    Posts:
    56
    I also have the same problem! have you found a fix?

    Thanks!
     
  5. planetfactory

    planetfactory

    Joined:
    May 18, 2016
    Posts:
    56
    ffdev78 and AmalexiM like this.
  6. GeorgeMincila

    GeorgeMincila

    Joined:
    Feb 28, 2016
    Posts:
    36
    Thanks for the tip. In Package Manager I only see IAP Purchasing 4.5, that is already installed. 4.6.0 does not appear for me.
     
    ffdev78 likes this.
  7. GeorgeMincila

    GeorgeMincila

    Joined:
    Feb 28, 2016
    Posts:
    36
    Ok, so I eventually just added a new gameobject with the script for initializing these Gaming Services. I got the code from the sample of the IAP package.
    So surprising that the IAPs broke without me changing anything there. Good thing I caught it and pulled the update from the App Store.
     
  8. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    182
    Hi @GeorgeMincila,
    You can add the new version directly into the manifest.json instead of using the package manager if you want.
     
  9. luisgualandi

    luisgualandi

    Joined:
    Oct 17, 2018
    Posts:
    23
    I got the same message after updating Unity to 2021.3.19f1.
    At first I tried @GeorgeMincila solution and the message stopped but other erros appeared. Random crashes upon calling UnityPurchasing.Initialize() and plugin not initializing properly/functions not working.
    Then I tried updating the In-App Purchasing package to version 4.6 and it seems to have worked.
    As @planetfactory pointed, I did had to update the code, by adding a new OnInitializeFailed instance with a different set of parameters:
    Code (CSharp):
    1. public void OnInitializeFailed (InitializationFailureReason error){}
    2. public void OnInitializeFailed (InitializationFailureReason error, string? message){}
    Version 4.6 was indeed not appearing on the package manager but it is on Project Settings > Services > In-App Purchasing.
    Conclusion: version 4.5.2 is broken on newer Unity versions
     
  10. naruto93

    naruto93

    Joined:
    May 6, 2015
    Posts:
    17
    Hi guys, I have the same issue with Unity 2022.2.
    Didn't have any response when call UnityPurchasing.Initialize
    I tried to use v4.6.0, but still not working.

    [Fixed]

    async void UnityServiceInitialize()
    {
    if (UnityServices.State == ServicesInitializationState.Initialized)
    {
    OnServiceInitialized();
    }
    else
    {
    try
    {
    var options = new InitializationOptions().SetEnvironmentName(Environment);
    await UnityServices.InitializeAsync(options);

    OnServiceInitialized();
    }
    catch (Exception exception)
    {
    var text = $"Unity Gaming Services failed to initialize with error: {exception.Message}.";
    Debug.LogError(text);
    }
    }
    }
     
    Last edited: Feb 27, 2023
  11. MontanaAnton

    MontanaAnton

    Joined:
    Feb 16, 2014
    Posts:
    14
    same issue on Unity 2021.3.19f1
    i pushed button to update to lates version 4.6.0
    after that implemented missing OnInitializeFailed methods for interface
    and it worked
    upload_2023-2-27_11-18-7.jpeg
     
  12. hexdecc

    hexdecc

    Joined:
    Oct 24, 2014
    Posts:
    146
    same issue, not worked above processes,
    i am getting this error
    Error initializing Unity Services: Failed to sort tree! It is likely there is a missing required dependency:

    {

    "ordered": [

    {

    "packageHash": 654700016,

    "packageProvider": "CorePackageInitializer",

    "packageDependencies": []

    }

    ],

    "packages": [
     
  13. hexdecc

    hexdecc

    Joined:
    Oct 24, 2014
    Posts:
    146

    which unity version did you use?

    2022.2.6 no visible 4.6.0 iap package.
     
  14. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    231
    Hello hexdecc,

    Could you try the solutions described in this thread?
    If this doesn't work, could you provide the answers to these questions:
    • Can you give us the whole logs?
    • Can you specify your Android build configuration ? Mono or IL2CPP, API Compatibility level, Development build, ...
    • Can you share with us your project's manifest ?

    We also have this other ongoing thread with the same issue you are having.
     
  15. GeorgeMincila

    GeorgeMincila

    Joined:
    Feb 28, 2016
    Posts:
    36
    From here I can also see Purchasing Package 4.6.0 being available. In the Package Manager, still only 4.5.2 is displayed. That seems strange.
     
  16. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    182
    That is normal, it is due to a label tag not added to the 4.6.0 release.
    But you can add the 4.6.0 version directly into the manifest.json and you are good to go!
     
  17. andrew210

    andrew210

    Joined:
    Apr 23, 2014
    Posts:
    241
    Unity 4.6.0 doesnt work either though, receiving multiple error messages of:

    Exception: No such proxy method: UnityEngine.Purchasing.BillingClientStateListener.onBillingServiceDisconnected()

    And doing a search suggests is an error in 4.6.0 and to downgrade again. This is pretty woeful.
     
  18. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,261
    andrew210 likes this.
  19. SanteEtermax

    SanteEtermax

    Joined:
    Feb 2, 2023
    Posts:
    10
    Why not use interface method with default implementation (c# 8) with this OnInitializeFailed? Is it for keeping compatibility with Unity 2020?

    And more important, why did you release a minor version with breaking changes?
     
    Zamaroht and saxahan like this.
  20. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    182
    Hi @SanteEtermax,
    You are guessing right, we cannot use all C# capabilities due to backward compatibility for our LTS support.

    This thread is now closed. Feel free to reach out via a new thread if you encounter further issues.
    Thanks!
     
Thread Status:
Not open for further replies.