Can you deploy to a device via Gradle from the command line
One line sentence:
Build project & Install generated apk & Open app on device
$ ./gradlew installDebug && adb shell am start -n com.example/.activities.MainActivity
1. Build project, install generated apk to device
# at the root dir of project
$ gradle installDebug
2. Open app on device
$ adb shell am start -n yourpackagename/.activityname
Since you are using Gradle, you could simple add your own task in build.gradle
task appStart(type: Exec, dependsOn: 'installDebug') {
// linux
commandLine 'adb', 'shell', 'am', 'start', '-n', 'com.example/.MyActivity'
// windows
// commandLine 'cmd', '/c', 'adb', 'shell', 'am', 'start', '-n', 'com.example/.MyActivity'
}
then call it in your project root
$ gradle appStart
Update:
If you are using applicationIdSuffix ".debug"
, add .debug
to the appId only but leave the activity untouched:
'com.example.debug/com.example.MyActivity'
$ gradle installDebug
This will push the debug build apk to device, but you have to manually start the application.