Preparing Your Android Application
Before you can start testing your Android application, you will have to package the app and generate the .apk file.
Building The App
Google makes a lot of effort integrating Gradle with Android development. Therefore, the easiest and most recommended way to do so is to use Gradle.
Your project should have Gradle in it with. When creating an Android Studio project, Android Studio runs initial configuration, making sure that Gradle is present as an integrative part of the project.
The process is simple and pretty straight forward.
First, make sure that you are in the root of your project folder, not the app folder.
Then run the command:
Windows
gradlew assembleDebug
Linux or Mac
./gradlew assembleDebug
Once the builds is complete, locate the .apk file in the build folder.
Root folder of project → app → build → outputs → apk → app-debug.apk