Google Play 服务 - 不再与 IL2CPP 一起正常工作

Google Play Services - No longer work properly with IL2CPP

我遇到了一些有趣的事情。 在我的一个应用程序中,我有 Google Play 服务(IAP、排行榜、成就、最新版本、1.22)。 这很好用。我最近不得不将应用程序重建为 64 位。 现在,我注意到这些服务似乎只在第一次加载应用程序时有效。 如果我退出应用程序并重新打开它,服务将不再有效。 我发现这与应用程序在后台处于活动状态有关(因为 Android 并没有真正杀死该应用程序)。如果我从内存中清除该应用程序(向上滑动、终止任务或类似操作),然后重新打开该应用程序,Play 服务将再次运行。

有人也遇到过这个吗?在何处查看或修复的任何提示?

非常感谢!

更新: 我发现问题发生在从 MONO 转移到 IL2CPP 构建时(64 位需要)。 我已将 Unity IAP 和 Google Play Games 插件更新到最新版本,并将构建平台设置为 .NET 4.x。一切都已更新并且构建良好,但是,问题仍然存在。确认这是由于 IL2CPP。

更新2: 当它中断时,这是来自 LogCat:

的调试日志

06-01 11:56:47.132:I/UnityIAP(12788):使用继续标记调用 getPurchaseHistory:null 06-01 11:56:47.146: E/Unity(12788): InvalidOperationException: 创建 GameServices 对象时出错。检查 GamesNativeSDK 的日志错误 06-01 11:56:47.146: E/Unity(12788): 在 GooglePlayGames.Native.PInvoke.GameServicesBuilder.Build (GooglePlayGames.Native.PInvoke.PlatformConfiguration configRef) [0x00000] 在 <000000000000000000000000000000000>:0 06-01 11:56:47.146: E/Unity(12788): 在 GooglePlayGames.Native.NativeClient.InitializeGameServices () [0x00000] 在 <00000000000000000000000000000000>:0 06-01 11:56:47.146: E/Unity(12788): 在 GooglePlayGames.Native.NativeClient+<>c__DisplayClass21_0.b__0 (System.Int32 结果) [0x00000] 中<00000000000000000000000000000000>:0 06-01 11:56:47.146: E/Unity(12788): 在 System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder 活页夹, System.Object[] 参数,System.Globalization.CultureInfo 文化)<00000000000000000000000000000000> 中的 [0x00000]:0 06-01 11:56:47.146: E/Unity(12788): 在 UnityEngine.AndroidJavaProxy.Invoke (System.String methodName, System.Object[] args) [0x00000] in <00000000000000000000000000000000> :0 06-01 11:56:47.146: E/Unity(12788): 在 UnityEngine._AndroidJNIHelper.InvokeJavaProxyMeth 06-01 11:56:47.355:I/UnityIAP(12788):购买历史响应:0

-- 它似乎拒绝正确重新初始化,因为当我尝试在此休息期间购买商品时,我在日志中看到:

06-01 11:59:50.894:I/Unity(12788):BuyProductID 失败。未初始化。 06-01 11:59:50.894: I/Unity(12788): UnityEngine.Events.UnityEvent:调用() 06-01 11:59:50.894:I/Unity(12788):UnityEngine.EventSystems.ExecuteEvents:执行(GameObject、BaseEventData、EventFunction`1) 06-01 11:59:50.894: I/Unity(12788): UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, 布尔值, 布尔值) 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()

更新3: 发现这是Unity目前正在调查的一个已知问题: https://forum.unity.com/threads/unity-2018-3-android-4-x-5-x-il2cpp-crash-unityiap.681982/

同时,这里有一些解决方法: https://forum.unity.com/threads/android-2018-3-13-unitypurchasing-dont-initialize-after-application-quit.665497/


发现这是 Unity 目前正在调查的一个已知问题: https://forum.unity.com/threads/unity-2018-3-android-4-x-5-x-il2cpp-crash-unityiap.681982/

同时,这里有一些解决方法: https://forum.unity.com/threads/android-2018-3-13-unitypurchasing-dont-initialize-after-application-quit.665497/