Search Unity

Android Imediate crash after implementing unity IAP

Discussion in 'Editor & General Support' started by ODINKONG, Jul 19, 2019.

  1. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    25
    I recently Implemented unity cross platform IAP for one non consumable purchase and I also added the correlating info to the google play console.

    Another thing that seems relevant is I added
    OnApplicationPause(bool)
    and
    OnApplicationFocus(bool)
    in order to update a certain timer when the game is refocused or un paused.
    The game crashes immediately after these updates so I'm not sure what to make of this. It has never crashed like this before. I am also using ad mob and requesting an ad when the game starts. Here is the log



    07-19 01:19:32.558 3683 3770 I ActivityManager: Displayed com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity: +112ms
    07-19 01:19:32.566 12838 12865 E CRASH : pid: 12838, tid: 12865, name: UnityMain >>> com.EvilVillianGames.RavensPath <<<
    07-19 01:19:32.578 3683 4149 W InputDispatcher: channel '9649fa8 com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
    07-19 01:19:32.578 3683 4149 E InputDispatcher: channel '9649fa8 com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
    07-19 01:19:32.580 822 1002 E SurfaceFlinger: Failed to find layer (SurfaceView - com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity#0) in layer parent (no-parent).
    07-19 01:19:32.580 822 1002 E SurfaceFlinger: Failed to find layer (Background for - SurfaceView - com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity#0) in layer parent (no-parent).
    07-19 01:19:32.580 3683 4531 I WindowManager: WIN DEATH: Window{9649fa8 u0 com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity}
    07-19 01:19:32.580 3683 4531 W InputDispatcher: Attempted to unregister already unregistered input channel '9649fa8 com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity (server)'
    07-19 01:19:32.580 3683 5692 W ActivityManager: Force removing ActivityRecord{1280d63 u0 com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity t8}: app died, no saved state
    07-19 01:19:32.583 3683 4531 D InputDispatcher: Focus left window: Window{9649fa8 u0 com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity}
    07-19 01:19:32.583 3683 4531 D InputDispatcher: Window went away: Window{9649fa8 u0 com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity}
    07-19 01:19:32.807 822 2524 E SurfaceFlinger: Failed to find layer (Background for - com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity#1) in layer parent (no-parent).
    07-19 01:19:32.808 822 2524 E SurfaceFlinger: Failed to find layer (com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity#1) in layer parent (no-parent).
    07-19 01:19:32.808 822 2524 E SurfaceFlinger: Failed to find layer (Background for - com.EvilVillianGames.RavensPath/com.unity3d.player.UnityPlayerActivity#1) in layer parent (no-parent).
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,895
    As always, please simplify and narrow down where the issue occurs. Remove all extra code (like your OnApplicationPause, etc) and consider using Debug.Log which will show in the device logs. There are no IAP entries in your log, so it is not even initializing, so something else is going on. Please compare your implementation to the Sample IAP project here: https://forum.unity.com/threads/sample-iap-project.529555/ . Get the sample IAP project working, then copy the working code into your project. Your larger project should never be "broken"
     
    karl_jones likes this.
  3. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    25
    Thanks for the response. It didn't make much sense to me that unity in app purchases would cause this issue either, especially sense it was actually working in a previous build, but in this build I actually created a catalog for the in app purchases on the google play store. I'm not sure if any of this is relevant, but I did another test that has me extremely stumped. If I build the apk unsigned exactly as it is in its "broken" state and drop it right on the phone it works fine with no issues. However If I upload it to the closed alpha track on the play console and download it from there it crashes before the splash screen with that log. I have some debug.log calls but this happens before any of that gets started. It seems to have something to do with downloading the build from the play store. Any ideas on whats going on here? I'm totally lost. This is the 13th build I have uploaded and all the others have worked just fine. Also the Application focus and pause commands don't take place in the first scene. There is actually very little in the first scene.
     
  4. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    25
    Ok I got it running. Seems like this was purely a google issue, and also it seems to be related to switching from the internal testing track to the alpha testing track. At least it was for me.

    Here is the solution that worked for me.

    https://forum.unity.com/threads/gam...b-build-worked-well-with-offline-apks.710378/
    ainscough
    So I figured mine out. However, it seems like it is most likely a different problem then what you guys are experiencing.

    My story was:
    1) Everything worked fine on the internal release track for about 15 builds in a row
    2) Got Google Play Beta approval
    3) Downloaded the game on the Beta build
    4) Black screen as mentioned above
    5) The same Beta build still worked on other people's phones

    The main problem was that somehow the Google Play cache must have gotten either a duplicate entry for the game or some other data glitch. Therefore, when I tried to open as a direct from Unity build (without uploading to Google Play), it worked fine because Google Play wasn't handling the registration of it. I have a feeling the game was trying to read part of one build and part of another or something similar.

    The fix was:
    1) Uninstall your game
    2) Go to your phones Settings -> Apps
    3) Go to Google Play Store and tap the Force Stop button
    4) Go to the Storage screen (by clicking on the Storage line item under Force Stop) and tap the Clear Data button - this will also active the Clear Cache button. If it doesn't, clear the cache too.
    5) Follow steps 3 and 4 for the Google Play services App
    6) Restart your phone (this part was necessary - I tried it without doing this and the fix didn't initially work)
    7) Redownload your game from Google Play
    8) It should start up normally.

    Hopefully this helps someone else. I spent 20+ hours and 4 days ripping my game down to the bones and it wasn't really even a Unity problem...