Search Unity

[Solved] [Android,2018.3.13] UnityPurchasing don't initialize after Application.Quit

Discussion in 'Unity IAP' started by MohHeader, Apr 21, 2019.

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

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    24
    Hello ,,

    So the issue goes like that.
    On Android start an application built with Unity 2018.3.13 and initialize the Purchasing as follow
    Code (CSharp):
    1. UnityPurchasing.Initialize(this, builder);
    it would work just normally and the OnInitialized method would be called normally
    Code (CSharp):
    1. void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    now Quit the app using Application.Quit or natively through Android Java code as follow :

    Code (CSharp):
    1.  
    2. //Author @digitalmoka
    3. using (AndroidJavaClass javaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
    4. using (AndroidJavaObject javaActivity = javaClass.GetStatic<AndroidJavaObject>("currentActivity"))
    5. {
    6.             javaActivity.Call<bool>("moveTaskToBack", true);
    7.             javaActivity.Call("finish");
    8. }
    9.  
    Start app again, and neither OnInitialized nor OnInitializeFailed, will be called.

    To make it work again as normal, kill the app ( from the Android Apps Menu ), then start the app and it would just work normal again.

    through the logs ( adb logcat ) I don't see anything unusual !

    IAP version : 1.22.0

    Thanks
     
    Last edited: Apr 22, 2019
    Duke_Hwang and Fronne like this.
  2. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    24
    @digitalmoka had the same issue, but was solved - as he stated - through using the java code listed before.
    he is the original poster of that code BTW.
     
    Last edited: Apr 22, 2019
    Fronne likes this.
  3. Fronne

    Fronne

    Joined:
    Sep 25, 2014
    Posts:
    109
    I had the same issue too with 2018.3.12 and with 2018.3.13. It runs once without problems but when you exit and restart the App, IAP is not initialized. No problems with 2018.3.11 and before...

    The fix from digitalmoka worked for me but not for everone...

    See thread 1 (last posts) for more information about this subject...
    See thread 2 for Error: called non-existent method System.Boolean UnityEngine.VR.VRSettings::get_enabled...
    See thread 3 for not working solution (in my case)...

    <off topic>
    The API Updater doesn't run automaticly with 2019.1.0, I have to trigger it myself with some deprecated code. I followed all steps to delete and import the folders several times but I was NOT able to get IAP running, I get the thread 2 Error all the time...
    </off topic>
    1. https://forum.unity.com/threads/cra...when-use-androidjavaproxy-class.627637/page-4
    2. https://forum.unity.com/threads/exc...r-vrsettings-get_enabled.518868/#post-4424164
    3. https://forum.unity.com/threads/iap-troubleshooting-remove-and-reinstall-unity-iap.511747/
    I'm using Easy Mobile Pro for Ads and IAP, everything works fine with 2018.3.11 and before. I noticed (on iOS) when a restore event was triggered, a purchase completed event is triggered after the restore event too wich triggers an Error. Android doesn't need to Restore so restore is disabled on Android...

    I solved this issue with a simple bool (canPurchase) to disable purchasing after a restore event and than IAP works without a problem, I just tell this to be complete...

    Upgrading a project with IAP to a new Unity version should be simple and should always work, we depend on good functionallity for Ads and IAP, that should never cause so many problems, just my $0,02...

    Cheers!
    Franco Palmieri - Fronne
     
    Last edited: Apr 21, 2019
    SamOYUnity3D and MohHeader like this.
  4. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    24
    this one worked for me, as it don't quit the app it just send it back to the background.
    I think this is a very good temp solution, until we got a fix

    Thanks @toberr
     
    Fronne likes this.
  5. MohHeader

    MohHeader

    Joined:
    Aug 12, 2015
    Posts:
    24
    Thanks @Fronne for the follow-up, hope we have a fix soon.
     
    Fronne likes this.
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,501
    We are looking into this.
     
    Fronne likes this.
  7. glenhunter

    glenhunter

    Unity Technologies

    Joined:
    Apr 2, 2019
    Posts:
    70
    We've been able to reproduce the problem.

    A temporary solution would be to call

    Code (CSharp):
    1. System.Diagnostics.Process.GetCurrentProcess().Kill();
    Before

    Code (CSharp):
    1. Application.Quit();
    Whereby

    Code (CSharp):
    1. void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    Will trigger when you reboot the app.

    Be sure to test before publishing. Hopefully, we can get a fix deployed in the next release.
     
    Last edited: May 9, 2019
    better_walk_away and Fronne like this.
  8. Fronne

    Fronne

    Joined:
    Sep 25, 2014
    Posts:
    109
    This doesn't work, the App doesn't Quit and I had a crash on startutp after a new install...

    Managed Stack Trace:

    System.Diagnostics.Process.GetProcessHandle (System.Int32 access, System.Boolean throwIfExited) (at <00000000000000000000000000000000>:0)
    System.Diagnostics.Process.Kill () (at <00000000000000000000000000000000>:0)
    SettingsManager+<QuitFamory>d__30.MoveNext () (at <00000000000000000000000000000000>:0)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <00000000000000000000000000000000>:0)

    Before I Quit, I run a Coroutine to save some Data to my DataBase, perhaps the Coroutine is Killed before it's finished, causing a crash...

    Cheers!
    Franco Palmieri - Fronne
     
    Last edited: May 11, 2019
  9. glenhunter

    glenhunter

    Unity Technologies

    Joined:
    Apr 2, 2019
    Posts:
    70
    Perhaps - you could always create a callback function for when the database has finished - you can then process your Application.Quit(); ?
     
  10. Fronne

    Fronne

    Joined:
    Sep 25, 2014
    Posts:
    109
    This works perfect with Mono...
    Code (CSharp):
    1.  
    2.  
    3.     IEnumerator QuitFamory ()
    4.     {
    5.         yield return new WaitForSeconds (0.25f);
    6.         settingsPanel.GetComponent<Animation>().Play ("ClosePanel");
    7.         while (settingsPanel.GetComponent<Animation>().isPlaying) {
    8.             yield return false;
    9.         }
    10.  
    11.        // More Irrelevant Code...
    12.  
    13.         yield return WebManager.instance.AddInteger ("_Stats", "totalPlayTime", Fronne.sessionTime, Fronne.device);
    14.  
    15.         #if UNITY_ANDROID && !UNITY_EDITOR
    16.         Invoke ("QuitAndroid", 0.25f); // Kill and Quit outside this Coroutine for Android...
    17.         #else
    18.         Application.Quit ();
    19.         #endif
    20.     }
    21.  
    22.     void QuitAndroid ()
    23.     {
    24.         // Unity Fix -> https://forum.unity.com/threads/android-2018-3-13-unitypurchasing-dont-initialize-after-application-quit.665497/#post-4520578
    25.         System.Diagnostics.Process.GetCurrentProcess().Kill();
    26.         Application.Quit ();
    27.     }
    ...but with IL2CPP it results in a crash:

    Managed Stack Trace:

    System.Diagnostics.Process.GetProcessHandle (System.Int32 access, System.Boolean throwIfExited) (at <00000000000000000000000000000000>:0)
    System.Diagnostics.Process.Kill () (at <00000000000000000000000000000000>:0)
    SettingsManager.QuitAndroid () (at <00000000000000000000000000000000>:0)


    System.Diagnostics.Process.GetCurrentProcess().Kill(); and Application.Quit(); are placed outside the Coroutine, because I think the Coroutine is Killed before or during Apllication.Quit(); is executed (Stack Trace Previous Post)...

    <edit>
    Mono is not a durable option, read the details here...
    </edit>

    Unity 2018.4.0f1
    Cheers!
    Franco Palmieri - Fronne
     
    Last edited: May 12, 2019
  11. magehernan

    magehernan

    Joined:
    Jul 6, 2012
    Posts:
    5
    i have the same problem, with unity 2018.3.13 and 2019.1.2
    The only thing for me works is killing the process from java overriding the main activity with a extension of unityplayeractivity and onDestroy of the activity put this

    Code (CSharp):
    1.  
    2. protected void onDestroy(){
    3.   super.onDestroy();
    4.   android.os.Process.killProcess(android.os.Process.myPid());
    5. }
    6.  
    now unity close and java call this an close the process before it shows the leaking serviceconnection and we i start the game again the iap and google play games is working.
     
    Fronne likes this.
  12. ThisGuise

    ThisGuise

    Joined:
    Oct 20, 2015
    Posts:
    5
    We just tried a build with the new Unity version (2018.4.1f1) and the problem seems to still be there. Any new timeframe on a fix for this issue?
     
  13. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,501
    No timeframe yet. You would be advised to try the mentioned workarounds in the meantime.
     
  14. Duke_Hwang

    Duke_Hwang

    Joined:
    Nov 23, 2014
    Posts:
    3
    I solved it by making a native plugin( .aar ) which just executes exit(0) in Java.
    It works pretty well but I'm just worried that Playerpref wont work out since it saves user data when Application.Quit is executed.

    http://lancekun.com/blog/wp-content/uploads/2019/05/quit_helper.zip
    After you extract this zip file, just locate aar file into Assets/Plugins/Android/
    then use below code instead using Application.Quit()

    Code (CSharp):
    1. public static void Quit()
    2. {
    3.     AndroidJavaClass ajc = new AndroidJavaClass("com.lancekun.quit_helper.AN_QuitHelper");
    4.     AndroidJavaObject UnityInstance = ajc.CallStatic<AndroidJavaObject>("Instance");
    5.     UnityInstance.Call("AN_Exit");
    6. }
    I tested this solution in below build environment.
    Unity3d 2018.3.14f / Android Gradle / IL2CPP ( all architectures )
    also tested on devices below
    Samsung Galaxy S4, 5, 7, Note 5, 9

    I wrote the article regards this issue, but sadly it's written in Korean
    http://lancekun.com/blog/?p=599

    @MohHeader I hope this solution can help your problem.
     
    Last edited: May 31, 2019
    raidelindie, DeniMN, Emanx140 and 8 others like this.
  15. Frolll

    Frolll

    Joined:
    Feb 17, 2017
    Posts:
    3
    I have the same problem. ADB displays message: "Scripting proxy object was destroyed, because Unity player was unloaded". How to fix?
     
  16. glenhunter

    glenhunter

    Unity Technologies

    Joined:
    Apr 2, 2019
    Posts:
    70
    Unfortunately, there's no official fix as of yet. However, Duke_Hwang appears to have found a temporary solution.

    If Korean isn't your native language - open the link in Chrome right click > translate to English.
     
  17. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    77
    Wow, that bug is really annoying and it's known for two month already..

    Could we please get an update about the current process on Unitys' side?
     
    ArtmeVy and Fronne like this.
  18. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,501
    We will try to get this into the next release, no ETA at this time however.
     
    Fronne likes this.
  19. skulluo-w

    skulluo-w

    Joined:
    Mar 13, 2016
    Posts:
    4
    Wait whattttt??????? I'm having this issue, it took me a whole day to find out it was Unity's bug.
    And I cant use
    "System.Diagnostics.Process.GetCurrentProcess().Kill()"
    Throwing this Exception:

    System.ComponentModel.Win32Exception (0x80004005): Success
    06-14 20:58:45.173 15192 15234 E Unity : at System.Diagnostics.Process.GetProcessHandle (System.Int32 access, System.Boolean throwIfExited) [0x00000] in <00000000000000000000000000000000>:0
    06-14 20:58:45.173 15192 15234 E Unity : at System.Diagnostics.Process.Kill () [0x00000] in <00000000000000000000000000000000>:0
    06-14 20:58:45.173 15192 15234 E Unity : at Exit.Quit () [0x00000] in <00000000000000000000000000000000>:0
    06-14 20:58:45.173 15192 15234 E Unity : at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    06-14 20:58:45.173 15192 15234 E Unity : at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0
    06-14 20:58:45.173 15192 15234 E Unity : at UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1].Invoke (T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0
    06-14 20:58:45.173 15192 15234 E Unity : at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0
    06-14 20:58:45.173 15192 15234 E Unity : at UnityEngine.E
     

    Attached Files:

  20. Maxim_AO

    Maxim_AO

    Joined:
    Jan 25, 2015
    Posts:
    14
    Great thanks, worked for us!
     
  21. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    77
    Yep, it seems like PlayerPrefs sometimes aren't saved.

    Unity, we need a bugfix here very soon!
     
  22. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,501
    Sometimes? Can you elaborate? Are you calling PlayerPrefs.Save before Application.Quit?
     
    Last edited: Jul 16, 2019
  23. ThisGuise

    ThisGuise

    Joined:
    Oct 20, 2015
    Posts:
    5
    We experienced that calling PlayerPrefs.Save right before the Quit did not always save all values properly. It seems it takes a little time for the values to be saves and it doesn't happen at all if the application is shut down in that time.


    On a positive note. I have just done a quick test on Unity 2018.4.3f1. It seems like this isn't a problem anymore. Can anyone else confirm this also?

    EDIT!! After doing a proper build (IL2CPP, Android App Bundle) I am now getting a hard crash on the second start up after doing Application.Quit(). Unsure if it is related to this or not.
     
    Last edited: Jul 3, 2019
  24. Tanek

    Tanek

    Joined:
    Apr 19, 2016
    Posts:
    23
    Is there an issue on issuetracker.unity3d.com so that we can track this?
    It is impacting Google Play Games integration too ( https://github.com/playgameservices/play-games-plugin-for-unity/issues/2562 ) and we are currently unable to release an updated version. And that's because for this release we had planned an update from Unity 2018.2.21f1 to 2018.4, we even updated to 2019.1.8f1 to see if this was fixed (partially fooled by this issue https://issuetracker.unity3d.com/is...on-errors-when-calling-application-dot-unload that seemed connected and it's shown as fixed in 2019.1).
    I will now try one of the workarounds but I definitely don't feel safe invoking a kill process before the Application.Quit() in a release that is bound to go in production.
    And we are evaluating reverting to 2018.2.21f1.
     
    nickeron and xman800 like this.
  25. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    165
    Google demands this to feature your app on the store.

    I'm having to remove this from my game until Unity fixes the issue. When my game is closed using application.quit it's throwing a crash error to google, who is now complaining that my game crashes too much (I have 2% crashes daily because of this!), which means it will drop on search results.

    And when the game is restarted googleplay services doesn't work.
     
    Last edited: Jul 4, 2019
    xman800 likes this.
  26. Asse1

    Asse1

    Joined:
    Jan 9, 2013
    Posts:
    77
    Games are left by pressing the back-button and confirming to quit. Just downloaded Township to test this behaviour.

    In addition, we need to quit the game when a savegame from the cloud has been downloaded manually.

    Now we need to implement saving the PlayerPrefs at an earlier point and test and deploy this change.
     
    xman800 likes this.
  27. xman800

    xman800

    Joined:
    Feb 27, 2017
    Posts:
    18
    Why isn't Unity giving this higher priority? This is affecting all Google Play Services (purchasing, achievements, leaderboards) across all versions of Android whenever the game is relaunched after Application.Quit() is called.

    Also, this is a REGRESSION. It worked fine with Unity 5.6.6f2. (The app was completely exited when calling Application.Quit() in that version, which prevented the problem, vs newer versions of Unity, where the app is still left running in the background.)

    @JeffDUnity3D, can you please look into getting this higher priority?
     
    Last edited: Jul 4, 2019
    Fronne, nickeron, _geo__ and 2 others like this.
  28. Tanek

    Tanek

    Joined:
    Apr 19, 2016
    Posts:
    23
    and please
     
  29. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,501
    The IAP team is aware, but I do not expect a resolution any time soon unfortunately
     
  30. Fronne

    Fronne

    Joined:
    Sep 25, 2014
    Posts:
    109
    And 4 weeks later​

    That's a complete different story, I don't understand why something important like IAP (and Ads) have such a low prioriy, Unity can do better than that! You don't need rocket science to solve this problem, just a matter of hours to solve it...

    We have to rely on IAP (and Ads) services, just my $0,02...
     
    nickeron and xman800 like this.
  31. SBS_User

    SBS_User

    Joined:
    Apr 19, 2014
    Posts:
    64
    Same here and the only fixes is to write your own Quit functionality on Native like @Duke_Hwang did.
     
    nickeron likes this.
  32. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,501
    Agreed! Except it's hours (or less) to solve it, then weeks/months of integration/QA testing and then the release process. The testing takes so long because the number of OS's and devices we need to test on. The test matrix is quite large and we have to manage the source updates done by hundreds of developers.
     
    nickeron and Fronne like this.
  33. Fronne

    Fronne

    Joined:
    Sep 25, 2014
    Posts:
    109
    Thnx for making that clear! I didn't realise a simple "bug" need so many steps before a fix can be released...
     
    nickeron likes this.
  34. achimeno

    achimeno

    Joined:
    Nov 13, 2014
    Posts:
    9
    My temporal solution:
    • Unity 2018.3.10f1
    • Scripting Backend: IL2CPP
    • Managed Stripping Level: Low

    2n solution:
    • Unity 2018.3.10f1
    • Scripting Backend: IL2CPP
    • Managed Stripping Level: Hight
    • AndroidManifest.xml
      • android:allowBackup="false" tools:replace="android:allowBackup"
     
    Last edited: Jul 12, 2019
    neonxu likes this.
  35. Adeetheknights

    Adeetheknights

    Joined:
    May 23, 2018
    Posts:
    3
    Same here

    when application quit these error show on logcat.
    IL2CPP build and strip engine code is false

    WindowManager: android.view.WindowLeaked: Activity com.volcano.bikestunts.trckyracingfree.UnityPlayerActivity has leaked window android.widget.PopupWindow$PopupDecorView{9a5bd85 V.E...... ......ID 0,0-640,100} that was originally added here
    at android.view.ViewRootImpl.<init>(ViewRootImpl.java:593)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:349)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
    at android.widget.PopupWindow.invokePopup(PopupWindow.java:1411)
    at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:1249)
    at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:1203)
    at com.google.unity.ads.Banner.showPopUpWindow(Banner.java:289)
    at com.google.unity.ads.Banner.access$800(Banner.java:44)
    at com.google.unity.ads.Banner$7.run(Banner.java:320)
    at android.os.Handler.handleCallback(Handler.java:836)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:232)
    at android.app.ActivityThread.main(ActivityThread.java:6802)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1103)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
    ActivityThread: Activity com.volcano.bikestunts.trckyracingfree.UnityPlayerActivity has leaked IntentReceiver com.unity.purchasing.googleplay.GooglePlayPurchasing$4@f2c2ea8 that was originally registered here. Are you missing a call to unregisterReceiver()?
    android.app.IntentReceiverLeaked: Activity com.volcano.bikestunts.trckyracingfree.UnityPlayerActivity has leaked IntentReceiver com.unity.purchasing.googleplay.GooglePlayPurchasing$4@f2c2ea8 that was originally registered here. Are you missing a call to unregisterReceiver()?
    at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1311)
    at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1006)
    at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1431)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1411)
    at android.app.ContextImpl.registerReceiver(ContextImpl.java:1405)
    at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:597)
    at com.unity.purchasing.googleplay.GooglePlayPurchasing.registerPurchasesUpdatedReceiver(GooglePlayPurchasing.java:503)
    at com.unity.purchasing.googleplay.GooglePlayPurchasing.<init>(GooglePlayPurchasing.java:122)
    at com.unity.purchasing.googleplay.GooglePlayPurchasing.instance(GooglePlayPurchasing.java:78)
    at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    at com.unity3d.player.UnityPlayer.c(Unknown Source)
    at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:232)
    at com.unity3d.player.UnityPlayer$e.run(Unknown Source)
    ActivityThread: Activity com.volcano.bikestunts.trckyracingfree.UnityPlayerActivity has leaked ServiceConnection com.unity.purchasing.googleplay.BillingServiceManager$1@a98f80a that was originally bound here
    android.app.ServiceConnectionLeaked: Activity com.volcano.bikestunts.trckyracingfree.UnityPlayerActivity has leaked ServiceConnection com.unity.purchasing.googleplay.BillingServiceManager$1@a98f80a that was originally bound here
    at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1508)
    at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1403)
    at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1592)
    at android.app.ContextImpl.bindService(ContextImpl.java:1564)
    at android.content.ContextWrapper.bindService(ContextWrapper.java:647)
    at com.unity.purchasing.googleplay.BillingServiceManager.bindToGooglePlayService(BillingServiceManager.java:114)
    at com.unity.purchasing.googleplay.BillingServiceManager$2.run(BillingServiceManager.java:149)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
    at java.lang.Thread.run(Thread.java:761)
     
  36. francismoy

    francismoy

    Joined:
    Jul 5, 2017
    Posts:
    10
    Just to add some more info. I'm using Unity 2019.1.9f1 and Unity IAP 1.22.0 and it seems to work fine when Application.Quit is called.
     
    JeffDUnity3D likes this.
  37. xman800

    xman800

    Joined:
    Feb 27, 2017
    Posts:
    18
    Thanks for the plugin, @Duke_Hwang. Why not just call PlayerPrefs.Save() before invoking your quit helper?
     
  38. Adeetheknights

    Adeetheknights

    Joined:
    May 23, 2018
    Posts:
    3
    using unity 2019.1.3f1 and unity IAP1.22.0 but still same error,
     
  39. UDN_7a2eceda-93d6-4468-b982-388651c336e0

    UDN_7a2eceda-93d6-4468-b982-388651c336e0

    Joined:
    Jul 25, 2016
    Posts:
    10
    When is it fixed? I have a same problem. Unity ads, Unity IAP, GPGS doesn't work.
    Unity 2018.4.4f1
     
  40. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,501
    I have heard that Unity 2019.3 addresses this issue
     
  41. UDN_7a2eceda-93d6-4468-b982-388651c336e0

    UDN_7a2eceda-93d6-4468-b982-388651c336e0

    Joined:
    Jul 25, 2016
    Posts:
    10
    How about 2018 ver?
    still have a temporary solution by Hwang only?
     
  42. UDN_7a2eceda-93d6-4468-b982-388651c336e0

    UDN_7a2eceda-93d6-4468-b982-388651c336e0

    Joined:
    Jul 25, 2016
    Posts:
    10
    I tried Hwang's solution but PlayerPref wasn't saved properly. I need a better solution..
     
    Last edited: Jul 23, 2019
  43. robertsze

    robertsze

    Joined:
    Jul 8, 2013
    Posts:
    63
    Same here, 2019.1.8f1, tons of user reported crashes
     
  44. Duke_Hwang

    Duke_Hwang

    Joined:
    Nov 23, 2014
    Posts:
    3
    I also got reported from users that some datas are missing even I called PlayerPrefs.Save before Quit which is calling by aar.
    The solution is that called PlayerPrefs.Save first, then give a delay of a few seconds before calling Quit method.
    In my case,

    Code (CSharp):
    1. PlayerPrefs.Save();
    2. yield return new WaitForSeconds(1.0f);
    3. AN_QuitHelper.Quit();
    Above code works pretty well without saving issue.
     
    DeniMN and xman800 like this.
  45. Tanek

    Tanek

    Joined:
    Apr 19, 2016
    Posts:
    23
    I am sorry if I insist on this but it's important because we need to track it and see in which release it's fixed (and also because I want to vote it and see that it is tracked on your side): is there an issue number on issuetracker.unity3d.com ?
    Please be aware that, as already stated, this affects also other integrations (e.g.: Google Play Games), not only Unity IAP.

    You are NOT suggesting that we should use an editor in Alpha for shipping code in Production, are you? :)
     
  46. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,501
    Correct, I am not suggesting that, only pointing out that the fix is starting to roll out.
     
  47. UDN_7a2eceda-93d6-4468-b982-388651c336e0

    UDN_7a2eceda-93d6-4468-b982-388651c336e0

    Joined:
    Jul 25, 2016
    Posts:
    10
    I tried "yield return new WaitForSecondsRealtime(0.5f);" Because Time.scale is 0 at the time.
    But Save function doesn't work properly.
    Probably I need to give more enough time or use WaitForSeconds instead of WaitForSecondsRealtime.
     
  48. Duke_Hwang

    Duke_Hwang

    Joined:
    Nov 23, 2014
    Posts:
    3
    I guess WaitForSecondsRealtime isn't affect by Time.scale.
    Anyway, we all know that Unity Tech will fix this bug sooner or later.
    So if I were you, I will try below attempt for temporary solution.
    Make new scene which only works for Quit feature, and make Time.scale 1 and then call Save and Quit functions.
     
  49. CybIam

    CybIam

    Joined:
    Nov 6, 2016
    Posts:
    50
    @Duke_Hwang did you check your approach in the folllowing scenario:
    1. User left app putting it in background (so no App.Quit)
    2. User back to app later and the app restarts.
    Does the OnInitialized triggered up?
     
  50. spotavi

    spotavi

    Joined:
    Aug 30, 2014
    Posts:
    31
    Need a fix. Alteast confirm the version of Unity that it has come out with.
    With the solution given. PlayerPrefs never gets saved !
     
Thread Status:
Not open for further replies.