How to use Firebase for building multiplayer Android games

Shukant Pal
We’ve moved to freeCodeCamp.org/news
3 min readFeb 10, 2019

--

Have you just built your board game for Android? Want to get it online? You are in the right place — let’s build it together!

We are going to implement match-making with the Firebase Realtime Database in this article. For that, you need Firebase setup in your Android project — see how to do that here.

Prerequisites

  • Firebase users — here, we are assuming you were able to login your user into Firebase using any method. This is necessary to identify whom to communicate with after the match-making is finished.
  • Gradle Dependencies — Add these to the dependencies block in your app module's grade file.
implementation 'com.google.firebase:firebase-core:16.0.6' implementation 'com.google.firebase:firebase-auth:16.1.0' implementation 'com.google.firebase:firebase-database:16.0.6'
  • You aren’t done after implementing match-making. That’s because you’ve only found two players that will play — but haven’t implemented how their moves will propagate over the network.

Our model

We will use a node in the Firebase database called the game room which will store all the active challenges that users have pushed. Each user will search for existing challenges within the game…

--

--