Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch custom Gradle Android build in Android Studio

Is there an easy way to build, install, and auto-launch a custom Gradle build in Android Studio?

Build android project android studio

When I press the "Play" (Run) button in Android Studio (with a typical Android project configuration), my project builds, installs it on the proper device, and then launches the app.

gradle configuration android studio

How can I do this with specific Build/Product flavors (using Gradle)? I've gotten as far as creating a Gradle configuration that runs the task "installFlavor1." This installs correctly, but it doesn't auto-launch the app.

like image 794
loeschg Avatar asked Oct 22 '13 22:10

loeschg


People also ask

How do I open an existing Gradle project in Android Studio?

If you are already using Gradle with your IntelliJ project, you can open it in Android Studio using the following steps: Click File > New > Import Project. Select your IntelliJ project directory, and click OK. Your project will open in Android Studio.

Where is Gradle build Android Studio?

The top-level build.gradle file, located in the root project directory, defines dependencies that apply to all modules in your project. By default, the top-level build file uses the plugins block to define the Gradle dependencies that are common to all modules in the project.

What is Gradle build in Android Studio?

Gradle is a build system (open source) that is used to automate building, testing, deployment, etc. “build. gradle” are scripts where one can automate the tasks.


1 Answers

You can always select a different buildVariant from the buildVariant window on Android Studio. And then if you press the run/play button you should be able to install and run the app on your device/emulator.

build variants

And also for me running gradlew install** on the terminal does not launch the app. If that's something you are looking for then take a look at build.gradle and buildhelper.gradle here

like image 75
Varun Avatar answered Oct 07 '22 23:10

Varun