When you target the Android platform, you get the possibility to upload your game to the Google Play app store. Using Google Play then gives you the option to add Google Licencing to your project, which is a protective measure to help reduce the risk of people running your game from sources other than Google Play.
To start with, you will need to open the project you wish to add Licencing to in GameMaker Studio 2, and then go to the Android Game Options and enable it:
Clicking this will prompt you to get the extension off of the Marketplace, so do that then go to your Marketplace Library (from the Marketplace menu at the top of the IDE) and find the extension, then click the download button:
Once it has downloaded, you need to add it to your project, so click the Import button to do that:
Once you have the extension installed, you then need to go to your Google Play dashboard and set up an App Listing for the game (from your Google Play console click the Create Application button and follow the on-screen prompts). You then need to get the Public Key from the Services and APIs section of the Developer Console:
You need to copy that to the clipboard then go back to GameMaker Studio 2 and add it into the Google Licencing Public Key section of the Android Game Options:
Now, with Google Licencing enabled, testing your game will show a message saying that the game could not be licenced and would you like to retry the connection or go to the store to buy the game. It looks like the licencing works, but you can't test the game anymore... to fix this so you can continue developing (and in the process see that the licencing works) you need to create an Alpha build of the project and upload it to the store.
Uploading an Alpha APK
Before you can test that the licencing works and keep playing your game on your devices, you will need to upload an APK of the project as an Alpha or an Internal Test build. To do this, you should first fill in the minimum required details for your app listing on the console, shown in the following image:
Once those three sections are completed, you then need to go to the section App Releases and click the Manage Alpha (or the Manage Internal Test) text. On the next page you want to create a New Alpha/Test Release.
IMPORTANT! At this point you will be asked if you want to use Google Play App Signing for your game. You should select OPT-OUT for this, as it is not compatible with the extension:
Once you opt out of the App Signing program, you can then upload an APK as an Alpha/Test build (if you don't know how to make an APK then please see here). Note that once you publish the Alpha/Test build, it can take a few hours for it to be accepted and another few hours for it to become "live" and available for testing.
Once the app is live as an Alpha on the Play store, you should be able to run the game now from GameMaker Studio 2 on your Android device and the previous message about retrying or buying will not be shown, indicating that the project has been licensed correctly.
Note: if you still get the licensing warning message, make sure that the email used to register the device is part of the defined Testers (as a developer your email should be automatically added).
You can continue to develop the game as normal now, or (if it is finished) go on to create a Release Build.