I've been looking for a good way to implement multiplayer in an Android strategy game I'm working on, using LibGDX. What I found:

  • The embedded LibGDX networking system
  • Kryonet
  • Google Play Services (I already used this system for a Unity game)

The only problem is that I don't know what system I want to use because I see multiple problems in each of these.

In LibGDX's networking and Kryonet, how can players connect to each other without having to tell each other their IP (which is not easy for everybody) ?
In Google Play Services, I don't know what are the requirement for users. Do the have to have Google Play, or maybe Google+ installed on their devices? Also, how easy is it to get Google Play Services to interface with LibGDX and Scene2D?


1 Answer 1


I can't speak for Google play services, but between the embedded LibGDX networking and Kryonet, I would suggest Kryonet. After all, it was written partially by the authors of Libgdx :) . It's also a big plus that you can integrate kryonet using gradle.

By "Libgdx's embedded networking" I assume you mean the sockets that Libgdx provides. Kryonet handles all of the socket intricacies for you. Why reinvent the wheel?

Kyronet uses a UDP broadcast to discover servers. Its super easy:

InetAddress address = client.discoverHost(54777, 5000);

(or there is a discoverHosts() function that allows you to get all servers listening on that port)

One caveat is that server discovery only works on the same subnet since UDP broadcasts usually don't travel beyond subnets without special configuration. If you want automatic server discovery outside of the same subnet, then you will likely have to use a matchmaking provider or create a matchmaking server yourself. It seems like Google play services may be a viable option for matchmaking.

To use Google Play services, there is an apk that does need to be installed on the user's device that needs to be present to interact with the services. It is best practice to check for Google Play services before you start using them and prompt the user to install them if they are missing. However, I would venture that most people these days use enough apps with Google Play services that it will already be on the user's device.

Google play services will only be available on the android platform so your android project will need to wrap these google play services in a callback object that would be injected into your core game. I.E.

Create interface in core project

public interface IGooglePlayServices{
   void callSomeService(object someParam);

Implement it in your android project

public class GooglePlayServices implements IGooglePlayServices {
   public void callSomeService(object someParam){

Then in your AndroidLauncher inject it into your game

public void onCreate(Bundle savedInstanceState) {

    AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
    IGooglePlayServices services = new GooglePlayServices();

    initialize(new MyGdxGame(services), cfg);
  • \$\begingroup\$ Thank you very much for this answer, only thing is, if I uses Kryonet, two devices that want to play together have to be connected on the same network, or one needs to manually enter the IP address of the other, right? \$\endgroup\$
    – Stolous
    Apr 6, 2016 at 9:54
  • 1
    \$\begingroup\$ Correct. The third option is to use some server that your game contacts that will communicate the ip address of one device to the other. (Google Play Services may do this so you may be able to use a hybrid of Google play and Kryonet) \$\endgroup\$ Apr 6, 2016 at 15:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .