I added a key from another test project to the main one. Then I opened https://console.developers.google.com/ and added this key with a new application name (as Lin Tao wrote), but that did not help.
Then I added a new type of activity (the "Activity on Google Maps" template in the gallery) and opened the google_maps_api.xml file. From there, I again found a link, for example https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=06:F2:F4:CD...applicationName .
I opened app/build.gradle , found the value of applicationId using applicationIdSuffix , if it exists, and connected, for example, in com.example.myapp.debug . In the link, I changed applicationName to this new value and opened the link.
Again created a new project, generated a new key and edited it, wrote the package name and SHA-1 fingerprint, as @Linh Dao wrote. Then saved. If you later find this key, find your project in the Google console and open the credentials.
I deleted the unnecessary activity card and saved it in AndroidManifest
<meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key" />
in the application tag.
UPDATE
A few months later I got the same exception in the debug assembly. As I understand it, I installed the wrong API key.
In LogCat, I saw this exception:

Then I opened https://console.developers.google.com/ , the project was opened and clicked "SDK Cards for Android".

Go to the Credentials tab (you can also see https://developers.google.com/maps/documentation/android-sdk/signup for information). Click your API key.

On the API key page, under β Key restrictions set Application restrictions . Click + Add package name and fingerprint .
Enter the name of your package from LogCat above (e.g. com.your_package.debug). Enter your fingerprint from LogCat (91: D6: ...: F7). Save it.
As @ Ahamed Rasheed wrote, I invalidated the caches, cleaned and rebuilt the project.