Use this link to create a project in Google Developers Console and automatically turn on the YouTube Data API. Click on Continue and wait until the project is created. 

Once the project is created, you will get a message that the API is enabled. Click on Go to credentials. On the next page, you will see a screen informing you to Add credentials to your project. Click on Cancel as we will create the credentials in the next step.  

Now, select the Credentials tab from the left section, click on CREATE CREDENTIALS , and then select the API key option as shown below.

Once the API key is created, you will be shown a dialog with your API key. Copy the API key as you will need it in the next step.

Go to the Android Studio project and open the file present in the Gradle Scripts directory. Copy your API key in the YT_API_KEY string and click on Sync Now.

Currently, the name of the project that you created is auto-assigned and may look something like My Project. Let's rename it to something you want. Renaming the project will also make it easier to link the project with Firebase which we will be doing in the next section.

From the top right corner, click on the three-dot menu and select Project settings.

Rename the project and click SAVE.