Search Unity

Google Play Services - No longer work properly with IL2CPP

Discussion in 'Unity IAP' started by kamicompute, Jun 5, 2019.

  1. kamicompute

    kamicompute

    Joined:
    Jun 5, 2019
    Posts:
    8
    Hello all,
    I came across something funny. In one of my apps, I have Google Play services (IAP, Leaderboard, Achievements, latest version, 1.22). This worked fine. I recently had to rebuild the app as 64-bit. Now, I notice that these services only seem to work the first time the app is loaded. If I quit the app, and reopen it, the services no longer work. I found that this is related to the app being active in the background (as Android doesn't really kill the app). If I clear the app from memory (swipe up, kill task or similar), and reopen the app, the Play services work again.

    Did anyone come across this as well? Any tips where to look at or fixes?

    Much appreciated!

    UPDATE: I've found that the issue occurs when moving from MONO to IL2CPP builds (which is required for the 64-bit). I've updated Unity IAP and Google Play Games plugin to the latest versions, and set the build platform to .NET 4.x. All has been updated and builds fine, however, the issue remains. Confirmed this is due to IL2CPP.

    UPDATE2: When it breaks, this is the debug log from LogCat:

    06-01 11:56:47.132: I/UnityIAP(12788): Calling getPurchaseHistory with continuation token: null 06-01 11:56:47.146: E/Unity(12788): InvalidOperationException: There was an error creating a GameServices object. Check for log errors from GamesNativeSDK 06-01 11:56:47.146: E/Unity(12788): at GooglePlayGames.Native.PInvoke.GameServicesBuilder.Build (GooglePlayGames.Native.PInvoke.PlatformConfiguration configRef) [0x00000] in <00000000000000000000000000000000>:0 06-01 11:56:47.146: E/Unity(12788): at GooglePlayGames.Native.NativeClient.InitializeGameServices () [0x00000] in <00000000000000000000000000000000>:0 06-01 11:56:47.146: E/Unity(12788): at GooglePlayGames.Native.NativeClient+<>c__DisplayClass21_0.b__0 (System.Int32 result) [0x00000] in <00000000000000000000000000000000>:0 06-01 11:56:47.146: E/Unity(12788): at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0 06-01 11:56:47.146: E/Unity(12788): at UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000>:0 06-01 11:56:47.146: E/Unity(12788): at UnityEngine._AndroidJNIHelper.InvokeJavaProxyMeth 06-01 11:56:47.355: I/UnityIAP(12788): Purchase history response: 0

    -- It seems it refuses to re-initialize correctly, as when I try to purchase an item during this break, I see this in the log:

    06-01 11:59:50.894: I/Unity(12788): BuyProductID FAIL. Not initialized. 06-01 11:59:50.894: I/Unity(12788): UnityEngine.Events.UnityEvent:Invoke() 06-01 11:59:50.894: I/Unity(12788): UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) 06-01 11:59:50.894: I/Unity(12788): UnityEngine.EventSystems.StandaloneInputModule:processTouchPress(PointerEventData, Boolean, Boolean) 06-01 11:59:50.894: I/Unity(12788): UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents() 06-01 11:59:50.894: I/Unity(12788): UnityEngine.EventSystems.StandaloneInputModule:process()

    UPDATE3: I notice when I call a signout from the playservices, and force the user to sign in again on (re)loading the app, it works. However, this clearly is not an elegant solution, as you would want the app to remember the Google Play logon from last time. This does confirm the issue is triggered by an already existing / cached logged on user.
     
  2. kamicompute

    kamicompute

    Joined:
    Jun 5, 2019
    Posts:
    8
    Ignore Update 3; signout doesn't work in all cases.
     
  3. kamicompute

    kamicompute

    Joined:
    Jun 5, 2019
    Posts:
    8
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Do you have a Quit button in your app? Personally, I've never seen a production app that has a quit button, either on Android or iOS. I suspect there are a few, but they are rare, and no need to point them out. Granted, this is not directly addressing your question, just a personal observation. We are aware of the issue, and looking into it. No time frame yet.
     
  5. kamicompute

    kamicompute

    Joined:
    Jun 5, 2019
    Posts:
    8
    Hello Jeff,

    Thanks for your reply :)
    I do have a quit button, but it does the same thing as 'Escape' via the android.
    The menu just felt incomplete without it ;)

    I've seen the workaround on the other threads, and indeed succesfully implemented the workaround (the quit helper Java plugin) proposed here (which is now implemented as the 'Quit button / escape button' action:
    https://forum.unity.com/threads/and...ont-initialize-after-application-quit.665497/

    Thanks for your actions on this, I'll wait for the official fix.