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:
Some of these sections require you to upload an APK first, so 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 CONTINUE for this, as it is required for the extension to work:
Once you opt into 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). Once it's uploaded you should then continue to fill out the rest of the relevant app listing details (like content rating or pricing), and then when all is correct (you will see green ticks beside the relevant items) you can return to the Alpha/Test section, review the details and publish.
IMPORTANT! When you opt in to the Google Licencing, you will need to sign each app with a UNIQUE KEYSTORE. This is a security measure implemented by Google as part of the licencing system.
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 delete any test APK's created by GameMaker Studio 2 that are on your device, and then download the version from the Google Play Store. This should be run once to ensure that licencing is working as required. 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.