Use the following commands to build application AAB bundle from command line

gradle bundle

or

gradlew bundle

Note that AAB bundle needs to be signed:

jarsigner -keystore $pathToKeystore app-release.aab $keyAlias

In Android Studio, choose Build - Generate Signed Bundle / APK and follow the dialog.