adb install -r ./app/build/outputs/apk/app-debug.apk #To install it to the device
adb shell am start -n $PACKAGE/$PACKAGE.$ACTIVITY #To launch the application in the device, where $PACKAGE is the development package and $ACTIVITY is the activity to be launched (the launcher activity).
I wrote this task to be able to install and also open the application on the device. Since I had multiple buildTypes and flavors with different application ids, it was not feasible to hard code the package name. So I wrote it like this instead: