Having studied how to do it myself, this is a step-by-step description that I would like to read when I started. I used information from several sources. None of these sources worked for me, and they differed in version numbers and where to insert things into build scripts. These instructions are the result of testing various combinations and filling in some gaps.

On the welcome screen, select "Run a new Android Studio project."

Fill in the application name and "company domain".

No changes are required on this page.

This example uses an empty action.

This example uses the name GroovyActivity for the Android main screen. A new project is now being created. When the android studio finished creating the project, it shows two open files:

Ignore the "rendering problem". It will be resolved later at compile time. Close two open files by clicking on the crosses of their tabs.
Open the build.gradle file (Module: app):

Paste the following code before the first line:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6' } }

Stop for a while to think about version numbers. Lines
classpath 'com.android.tools.build:gradle:1.1.0'
and
classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6'
contain version numbers. How do you know the version number to insert here? While you are reading these instructions, new releases may have appeared, and if you do not have specific version requirements, you will want to use the latest version of what is used here in the gradle script.
How do you find out about the latest available versions? It depends:
Notice that the editor highlighted com.android.tools.build: gradle: 1.1.0 with a yellow background color. When you hover over this text, a tooltip appears:

So, it looks like Android Studio is aware of the latest version of this thing and advises you to use it. Follow the tips and update this version number, as indicated by your version of Android-studio.
However, there is no such tooltip for this gradle - groovy -android-plugin.
What is going on here, anyway? As I understand it, these names and version numbers identify the names of the binary components that are used for your application or for creating your application, but they are also not part of android studio, and you should not find and install or compile them yourself. Instead, this script assembly indicates the location of the repository where these binary components are likely to be loaded. The jcenter () function seems to return the repository location. This repository is currently bintray.com.
To find out about the latest version of this plugin for Android gradle groovy, visit bintray.com using your web browser and use its search function. Find groovy -android-plugin. The initial result looks like as soon as I write this:

The exceptional amount of these results is a little discouraging. Hope they have some sort of relevant sorting. Looking through the first page, I see only 2 matching matches, and the last version number is 0.3.6.
After learning about the latest versions (at the time of this writing), the correct start to the gradle script is this code:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6' } }
To return to changing the gradle script, paste the following code after the line "apply plugin: com.android.application":
apply plugin: 'groovyx.grooid.groovy-android'

Finally, near the end of the gradle script, insert the line
compile 'org.codehaus.groovy:groovy:2.4.1:grooid'
so that it looks like this:
<T411>
Again, there is a version number here, you can find the latest version on bintray looking for * grooid.jar (yes, with a star as the first character). The list of results spans two pages, on the second page I find that 2.4.3 is the latest version:

After modifying the gradle file, you need to synchronize the gradle. gradle will sync if you exit Android Studio completely and restart it, so this is what I did at this point. This figure shows the synchronization after restart:

Later I found that this toolbar icon

starts synchronization.
After synchronization is complete, change the left panel from the "Android" screen to "Project" in the drop-down menu:

Now create and execute the project in the emulator at least once. I’m not sure that this will change, but if you don’t create and run your project now, and still remain only java sources, then your groovy sources will not be found after we switch to groovy. You can create and run a project using the launch icon on the toolbar or by quickly switching the F10 keys.
After completing your project in the emulator, go back to the left pane, which still displays the Project view. In this view, navigate to the app / src / main directory, which currently contains the java and res subdirectories, and the AndroidManifest.xml file.
Now you will create an additional “Java Folder” below the main one, using the context menu:

Be sure to use the menu item New-> Folder-> Java Folder, not New-> Directory, which will subsequently cause problems.
On the next screen

check the "Change folder location" checkbox and make sure that the name in the input field is src / main / groovy.
If you still have a gradle script open, you will see that it has been adapted and contains the name of the new directory in the line starting with "sourceSets". For a good measure, click the gradle sync icon to make sure everything is in sync correctly.

Next, you want the new groovy folder to contain the correct package path for the package name of your application. The only way I found for this is to create a new, temporary, java class with the context menu of the groovy folder,

and enter the name of this class, the full name of the package:

Make sure the package name is spelled correctly!
A new package will appear in the groovy folder and inside it - a temporary java class.
All groovy classes, as well as all java classes that somehow use the groovy classes, should live below the src / main / groovy directory, not the src / main / java directory. Now we can drag the Activity class from the java directory tree into the same package below the groovy directory:

Now the temporary class can be deleted (in the context menu), and the Activity class can be transferred from .java to .groovy by choosing Refactor-> Rename File from the context menu.

The .java file extension is simply replaced by the .groovy extension. In the same way, you can create new Java classes and rename their file to .groovy when you really want to create groovy classes. Now you can change the code in action to make sure that you actually have the groovy code in the Android app. Sentence:
Give the text "Hello World" to see the identifier in res / layout / activity_groovy.xml, for example:

Then programmatically change the text shown by this view using groovy string interpolation:

Create and run in the emulator:
