Search Unity

Integrating with Google Play & Game Center

Discussion in 'Getting Started' started by chrisparton1991, Jan 23, 2017.

  1. chrisparton1991

    chrisparton1991

    Joined:
    Jul 1, 2016
    Posts:
    14
    Hi all,

    I'm currently learning up on Unity with the intention to release a mobile game (or games) on the Android and iOS app stores.

    One area I'm struggling to find best practices for is app store integration. Since so many games do this, it seems like there should be some resources out there.

    I know about the Game Center integration and Google Play plugins, and I'm happy to study up on them, but is there a particular tutorial/repository/asset that is widely regarded as a solid starting point for this kind of integration?

    I'm mainly interested in learning about implementing achievements, leaderboards, and cloud saving.

    Thanks,
    Chris
     
  2. chrisparton1991

    chrisparton1991

    Joined:
    Jul 1, 2016
    Posts:
    14
  3. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    I meant to respond to your post when I first saw it, but got distracted.

    I can't comment on the asset you've linked to, but if it does everything it says it does, that's a great price. When I integrated iOS multiplayer for my game, many of these plugins didn't exist. I paid for a low-budget option first, which ended up being a broken mess before switching to prime31's plugins, which are expensive but work as advertised.

    At $20, you're not risking much, so I say give it a shot!
     
  4. chrisparton1991

    chrisparton1991

    Joined:
    Jul 1, 2016
    Posts:
    14
    Thanks Schneider21, I've purchased the asset but haven't yet gotten around to testing it out. It looks promising though!
     
  5. rsodre

    rsodre

    Joined:
    May 9, 2012
    Posts:
    229
    For a small project, it's the best fit. All in one, easy to use, works as expected.

    But, on a larger project, where I have 5 ad network and adapters, and Facebook Analytics, this package installs so much unneeded stuff that Unity can't build for Android anymore, I had to export the project to Android Studio, and I never succeeded to build it. It broke my Android build permanently and after two whole days struggling I decided to remove it and find other alternatives. Now I'm using unity-native-sharing for sharing and Very Simple Rating System for rating.

    Did you find anything for Game Center and Google Play Games yet?
    I also tried Very Simple Leaderboard and it lacks fetching scores and reporting/fetching achievements.
     
    Last edited: May 26, 2017
  6. chrisparton1991

    chrisparton1991

    Joined:
    Jul 1, 2016
    Posts:
    14
    Hey @rsodre, I've been using the Cross Platform Native Plugin without any real issues, though I agree that it installs a lot of junk.

    I think the most popular plugin for this stuff is Stan's Assets, but I think it costs about $80 AUD.

    I haven't tried building my game for iOS yet though, so I could hit some snags there...
     
  7. Andrea_Marchetti

    Andrea_Marchetti

    Joined:
    Apr 23, 2017
    Posts:
    9
  8. chrisparton1991

    chrisparton1991

    Joined:
    Jul 1, 2016
    Posts:
    14
    I'm still developing my game, but I'm using CPNP and it's been working fine on Android (haven't tested on iOS yet).

    I have cloud save, achievements and leaderboards implemented so far.
     
  9. Andrea_Marchetti

    Andrea_Marchetti

    Joined:
    Apr 23, 2017
    Posts:
    9
    good. because I did buy it and I had a problem with building it. A multidex issue... I asked for support but I didn't receive it. So I am not using it anymore in my game...
    Maybe next game I will try again to figure it out.
     
  10. chrisparton1991

    chrisparton1991

    Joined:
    Jul 1, 2016
    Posts:
    14
    I've found their support isn't the greatest. Stan's Assets, the most popular (but more expensive) alternative to CPNP doesn't appear to invest too much effort on their support either. Their forum site has an invalid SSL certificate and it's been spammed with hundreds of thousands of gibberish forum posts.

    One of the biggest shocks for me when getting into mobile dev using unity was the lack of out-of-box integration with Game Center and Play Services. A pity we have to rely on third parties to provide a unified API, none of them seem to be doing a great job of it.
     
  11. rsodre

    rsodre

    Joined:
    May 9, 2012
    Posts:
    229
    just9, Moonjump, PapaStout and 3 others like this.
  12. chrisparton1991

    chrisparton1991

    Joined:
    Jul 1, 2016
    Posts:
    14
    Nice find @rsodre! The CloudOnce API looks really nice, and it looks like it spews much less junk into your project than CPNP does. I think I'll have a crack at moving my game over to use CloudOnce instead. I'll post back when I've had a chance to play with it.
     
  13. chrisparton1991

    chrisparton1991

    Joined:
    Jul 1, 2016
    Posts:
    14
    I've finished replacing CPNP with CloudOnce. My initial integration caused my game to crash on sign in. I upgraded my Android SDK from v24 to v25 and that caused an "Error while saving blame file" issue, which I fixed by adding the following line into my Android manifest file (thanks to http://answers.unity3d.com/answers/1370675/view.html):
    Code (CSharp):
    1. xmlns:tools="http://schemas.android.com/tools"
    After doing that, everything worked fine. There are a few things I'm really liking about CloudOnce:
    1. The API is much simpler and more logical than CPNP's
    2. After configuring achievements, leaderboards and cloud variables, CloudOnce generates some C# classes with this information in it so you can access and manipulate these things in a type-safe fashion
    3. It's open source!
     
  14. mastercpj1

    mastercpj1

    Joined:
    Dec 17, 2013
    Posts:
    3
    Are the leaderboard in this plugin unique to all the platforms?
    As in, does this have a global leaderboard to show both Android and iOS users? :)
     
  15. chrisparton1991

    chrisparton1991

    Joined:
    Jul 1, 2016
    Posts:
    14
    Nope, the leaderboard displayed is a native iOS / Android one.
     
  16. SavedByZero

    SavedByZero

    Joined:
    May 23, 2013
    Posts:
    124
    Hey guys, this plugin looks cool, but the documentation seems pretty sparse and scattered. All I see are test mono behaviors that I add -- like that leaderboard button (main reason I'm doing this) -- and it brings up the Game Center login screen, but then tells me the Game Center doesn't recognize my app, so I'm clearly missing a step.
     
  17. Deleted User

    Deleted User

    Guest

    i can help you to build ur project without exporting it to android studio , i used gradle and enabled multidex , and the new version of unity now uses gradle as default building system . (If you still have any trouble )
     
  18. Deleted User

    Deleted User

    Guest

    for the multidex issue u can switch to gradle in build , and enable multi dex to reduce the limit count
     
  19. TheMax2015

    TheMax2015

    Joined:
    Mar 6, 2015
    Posts:
    12
    This looks a shame, as try loading the asset into the latest build of Unity 2017 and also Unity 5 and the asset does not create any editor menus to work with this.

    This is a real shame as looking at the documentation this looks like a really good asset to have and use.

    Not sure if others have had issues, or maybe I just missing something obvious?

    Thanks

    Max
     
  20. rpuls

    rpuls

    Joined:
    Feb 3, 2017
    Posts:
    101
    Hi, I have been looking into CloudOnce. But I'm getting a build error:

    'C:\Users\username\Documents\UnityProjects\project\Temp\StagingArea\android-libraries\GooglePlayGamesManifest.plugin' is missing AndroidManifest.xml file.
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()


    I'm not sure if this is because I am not meeting the requirements from the "getting started" guide:
    • Android 4.0 (API 14) or later
    • Android SDK Packages
      • Google Play services
      • Android Support Library
      • Android Support Repository
      • Google Repository
      • Android 6.0 (API 23) (doesn't affect min SDK version)
    The guide is not very clear what these things are, or where to get them and how to install/add them. - I mean I have the android SDK pointed correctly as I was perfectly able to build my game and run on my phone before, but I'm not sure if i have these packages... :s

    Did any of you have success building after adding CloudOnce? What did you do?

    Cheers!
     
  21. ZyntharNOR

    ZyntharNOR

    Joined:
    Sep 20, 2013
    Posts:
    16
  22. rpuls

    rpuls

    Joined:
    Feb 3, 2017
    Posts:
    101
    EDITED: solution to this problem is written in the end of this post.

    @ZyntharNOR Thank you very much for your answer! After digging a bit deeper in my android SDK manager I was able to locate óne missing part of the requirements, the "google play services" -that is now installed. I also seem to be missing the so called "android support library" but that is not available in my SDK manager for some reason. The docs from androiddocs.com is outdated (I believe) at least the screens from their SDK manager is not even close to how mine looks.

    You are right that I did go through the "Google Play Application ID setup" - I assumed that none of the services would be enabled by default, and I would be able to build my apk without going through any of the setting up. After all it states: "if you are releasing on Google Play, you must run the Application ID setup." I'm pretending like I'm not sure I would like to release on google play yet, and there fore should be able to build without setting up.

    But. After going through the google app id setup I got one step further, but now I ran into a manifest merge issue. There is many different manifest files and the error message is not clear about which of them is unable to merge.

    Error: Error while saving blame file, build will continue
    Error: The prefix "tools" for attribute "tools:overrideLibrary" associated with an element type "uses-sdk" is not bound.

    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()



    AndroidSDKToolsException: Unable to merge android manifests. See the Console for more details.
    UnityEditor.Android.AndroidSDKTools.DetectErrorsAndWarnings (System.String logMessages, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandInternal (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommandSafe (System.String javaExe, System.String sdkToolsDir, System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommand (System.String[] sdkToolCommand, Int32 memoryMB, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommand (System.String[] sdkToolCommand, System.String workingdir, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.RunCommand (System.String[] sdkToolCommand, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidSDKTools.MergeManifests (System.String target, System.String mainManifest, System.String[] libraryManifests, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit)
    UnityEditor.Android.PostProcessor.Tasks.GenerateManifest.MergeManifests (UnityEditor.Android.PostProcessor.PostProcessorContext context, System.String targetManifest, System.String mainManifest)
    UnityEditor.Android.PostProcessor.Tasks.GenerateManifest.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()


    I'm no good with decifering android build errors :/ do you by any chance have an idea of what I am missing this time?

    :)

    EDIT, solution:
    I found this post: https://github.com/googleads/googleads-mobile-unity/issues/423 which solved my problem. To be more precise, MuradDasi's post:

    I managed to make a build using:

     
    Last edited: Aug 15, 2018
  23. ZyntharNOR

    ZyntharNOR

    Joined:
    Sep 20, 2013
    Posts:
    16
    The latest version of CloudOnce (v2.6.2) includes a fix for the above AndroidManifest issue.
     
  24. Lo1s_

    Lo1s_

    Joined:
    Nov 11, 2018
    Posts:
    1
    I seem to have a problem logging into google play.
    I only see the green Google Play logo window then only a loading spinner and it hangs at that stage. I can press the back button to get to an account selection window, and pressing back on that will get me into the game, but of course I'm not logged into google play then.
     
  25. biodam

    biodam

    Joined:
    Jul 10, 2013
    Posts:
    17
    Hello there. I am testing the Cloud Once and until now it seems to be pretty robust.

    Was having a problem to log in to Google Play Game Services, in my case the problem was that the fingerprint SHA1 signature of the keystore that I'm using (the debug one for now) was not registered in the Google API Credentials (console.developers.google.com/apis/credentials).

    So if anyone is having this problem this may be one thing to check. Follow the Step 3 of this guide and register a new OAuth 2 credential so your build will be able to access the Google APIs that are needed by the Game Services.

    After this login, open achievements and leaderboards panel are working on Android with Cloud Once.

    Next step will be to test on iOS.

    EDIT: It worked!!!!

    EDIT 2: If you are having a problem with Unity 2018.3 check this post, in a nutshell after upgrading to Unity 2018.3 I deleted the AndroidManifest generated by CloudOnce.

    One more thing that I faced is not being able to log in, in my case was this, the app is on internal test so to test the play game services you need to add the testers as testers for the play games as well as testers for the app at "Play Console -> Game Services -> Testing".
     
    Last edited: Jan 10, 2019