What the question says really - can you issue any commands directly to gradlew via the command line to build, package and deploy to a device?
To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: On Windows: gradlew <task1> <task2> … e.g. gradlew clean allTests.
You can execute multiple tasks from a single build file. Gradle can handle the build file using gradle command. This command will compile each task in such an order that they are listed and execute each task along with the dependencies using different options.
Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.
$ gradle installDebug
This will push the debug build apk to device, but you have to manually start the application.
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With