By default, Android Studio builds the debug version of app, which is intended for use only during development, when you click Run. To change the build variant, go to Build > Select Build Variant in the menu bar. Select Build Variant menu item will be grayed out if project-level build.gradle file is opened in the Editor.

Build Variant in Non Native C++

To change the build variant, go to Build > Select Build Variant in the menu bar. Build Variants panel has two columns i.e. Module and Active Build Variant. Active Build Variant value shows the build variant the IDE deploys to connected device and is visible in the editor.

Build Variants menu in Android Studio
Build Variants menu in Android Studio

Above figure shows two build variant for module app. To switch between variants, click the Active Build Variant cell for a module and choose the desired variant from the list field.

Build Variants tool window can be found in View -> Tool Windows.

Build Variant in Native C++

Projects with native/C++ code, the Build Variants panel has three columns: Module, Active Build Variant, and Active ABI. Active ABI value determines the ABI that the editor uses, but does not impact what is deployed. To change the build variant or ABI, click the cell for the Active Build Variant or Active ABI column and choose the desired variant or ABI from the list.

Reference

Change the build variant