Search Unity

Unity IAP not initializing on android

Discussion in 'Unity IAP' started by roberto_sc, Jan 15, 2018.

  1. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Not sure about the spam warning, I will look forward to the requested information.
     
  2. MarcoPixion

    MarcoPixion

    Joined:
    Jan 29, 2018
    Posts:
    20
    Here are all the differences of my steps from your video (which just shows how to import and open a sample project):

    1) open with unity hub with 2019.1.0f2
    2) textmesh pro errors in the project: use .net 4
    3) create a unity link in the service window
    4) Service->IAP window: "Options" shows "Enter Key"
    5) Unity IAP -> IAP Updates -> I can just install 1.22.0 (not 1.20.1) -> no confirmation message shown

    - your video info ends here -

    6) switch to Android platform and build on device (Pixel 1)
    7) Run the build and press "Consumable" button -> App shows "Purchasing product: gold50"

    but the same error happens (find log attached again)

    I hope this helps.

    Fyi: I tried with the Codeless sample as well (which you provide in the next post) and the same error happens on press of the "Gold" button.
     

    Attached Files:

  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    It appears you missed a very important part, the pop up that asks you to Update the API, where you click "Yes, I made a backup". If you did not receive this, then the VR error would be expected. But more importantly, if you have textmesh pro errors, then the IAP import would fail. Before you import IAP, there must be zero compiler errors. This is likely your issue. As soon as you upgrade and see those errors, please try "Reset Packages to Default" from the Help menu, or remove the TexMesh Pro package from your project. Once your game runs OK in the Editor, THEN import IAP. There are known issues with Unity 2019 and IAP described here https://forum.unity.com/threads/notice-iap-issues-with-unity-2019.689647/
     
  4. MarcoPixion

    MarcoPixion

    Joined:
    Jan 29, 2018
    Posts:
    20
    That popup came out just like in your video and I did excatly what you showed.

    That's why i did not mention it.
    I listed the differences to your video. Just like you asked.

    As for the textmesh pro errors, they came out simply by opening your sample in Unity 2019.1.0f2 (so no, no problems "on my side", I believe, cause if you check the steps, I update the IAP package after solving those issues).
    The errors were there because .NET was set to 3.5. Setting it to 4 solved the issue immediately, then, again, I updated IAP (just like you suggested).

    Finally, again, I followed the instructions in your last link and the result is exactly the same (and I attached the log above).
     
    Last edited: Jul 23, 2019
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Understood, thanks for making it clear. Following those steps works for me, but I don't believe I was using specifically 2019.1.0f2, it seems the behavior changes between sub-versions. We are working to address issues with Unity 2019 and IAP in the next release hopefully available in a few weeks.
     
  6. giggioz

    giggioz

    Joined:
    May 11, 2017
    Posts:
    52
    Thank you so much for posting this.

    I solved with the workaround here
    https://forum.unity.com/threads/sol...r-application-quit.665497/page-2#post-4806218

    Using Unity 2019.1.2f1
     
  7. Helical

    Helical

    Joined:
    Mar 2, 2014
    Posts:
    50
    Some Android Devices might not Initialize with a Cellular Connection, a WIFI may be a requirement.

    Hi, i have a similar case to many people here.
    We do initialize Unity IAP like anyone else

    UnityPurchasing.Initialize(this, config);

    However, sometimes neither the callbacks gets called back.

    I also noticed that this happens when I dont have WIFI, and am testing on 4G. Using rouge 2 Android device. I am one of those people that like to work with my own device. So none of the QA seem to be able to reproduce this problem, since they dont have a SIM card.

    However Google gets blocked without WIFI on my phone, when only 4G is available.

    If I try to "Add Google Account" on my device in the settings. It also does not work without a WIFI connected.

    This is a general problem with Google, but also Unity should really timeout and inform us via their so called
    public void OnInitializeFailed(InitializationFailureReason error)


    [Update]
    After i have turned on WIFI and got the Unity IAP connected. Now turning off wifi and restarting App will properly initialize.
     
    Last edited: Jun 1, 2020
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    IAP requires an internet connection to initialize.
     
    Starbox likes this.
  9. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    he said 4G so he’s got a connection.

    unity IAP needs to call one of the two callbacks otherwise you have no clue what state you’ll be in.

    say for example someone opens the game and immediately opens the store. If unity IAP is not initialised I don’t know if i should show a loading message or an error message because unity IAP is neither initialised or failed, it’s a limbo state...
     
    Helical likes this.
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Unfortunately with no WiFi or Data connection, IAP can continue to poll and not return InitializedFailed in some situations. But if you have a connection, it should initialize immediately. If you don't get a success callback, assume you don't have IAP.
     
  11. Helical

    Helical

    Joined:
    Mar 2, 2014
    Posts:
    50
    Obviously, but 4G is not always sufficient for Google matters. For example I can't add a Google Account (unrelated to Unity apps) with a 4G connection.

    Only WIFI works for Google on my phone
     
  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, you can use 4G, I use it every day on my Verizon data plan for account management. It's very fast, I get 18 Mbps. Do you get an error?
     
  13. Helical

    Helical

    Joined:
    Mar 2, 2014
    Posts:
    50
    This for example is an image of me trying to Add a Google Account on my Phone with a 4G connection. Google obviously does not work, however i am able to send a screenshot to myself via Whatsapp.

    I believe this same crap is happening for the Unity Billing Initialize. Where they get stuck in a Limbo because of Google not operating without a WIFI on Android. WhatsApp Image 2020-06-01 at 8.24.59 PM.jpeg
     
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What is your connection speed? Just Google "speed test" from a browser on your device. If you don't get a successful initialization, simply assume IAP is not connected.
     
  15. Helical

    Helical

    Joined:
    Mar 2, 2014
    Posts:
    50
    In any way, this is the post that got me thinking that there might be a WIFI problem with Google. And We are actually doing everything correctly.

    https://android.stackexchange.com/q...-to-google-account-when-on-data-works-on-wifi

    I have had the same issues with Google Sign In package.
     
  16. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  17. Helical

    Helical

    Joined:
    Mar 2, 2014
    Posts:
    50
    around 40 MB
     
  18. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    40 Mbps over 4G, are you sure? That's more than WiFi, please show a screenshot from your device after doing the speed test. At any rate, we have no control over access to the Google servers over your network.
     
  19. Helical

    Helical

    Joined:
    Mar 2, 2014
    Posts:
    50
    But it would be nice, if you would invoke the
    public void OnInitializeFailed(InitializationFailureReason error)

    With a fail reason that would hint => could not reach Google servers, check connection and firewalls WhatsApp Image 2020-06-04 at 12.21.46 PM.jpeg
     
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We are a pass through service for the Google billing API, those initialization callbacks come from them. But that presents a problem if you are blocked from their servers but still have Internet access, like in your case. My suggested workaround should work in the meantime, you could implement a co-routine/timer to check for example.
     
    Helical likes this.