Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build local gradle app on remote server in Android Studio

The size of my current project including the dependencies is growing all the time, which means right now it takes around 2 minutes on my local machine to create the current gradle build.

We already have a CI system which is building on pushes, but is there also a way to use cloud-resources to build the local version and pull it back to the local machine for testing and debugging in the emulator or a connected device?

Yes a solution would be to buy a faster PC, but that doesn't really scale well as also our engineering team is growing all the time. So renting a cloudserver, which is doing the heavy CPU work would be a very economical option.

like image 876
Tobias Avatar asked Sep 21 '16 15:09

Tobias


People also ask

Where is the build Gradle file in 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.

How do I sync Gradle with Android Studio?

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.


1 Answers

  1. We can use mainframer or Mirakle to move the build process to remote machine. Check this article for more detail. We can run Docker container in remote-machine along with mainframer. Check this.

The basic principle upon which they both operate is that they open an SSH connection to the build executor, perform an rsync of your development folder to copy across any changes (such as edited source files) to the executor, run the build, and then perform a second rsync to copy the changes (including the compiled APK) back to your development machine.

  1. We can take advantage of Gradle build-cache server. Gradle is using the build cache since November 2016 and saw a median build time reduction of 15%. Check this and this for more information.

The recommended setup for the build cache is that your continuous integration server populates the remote build cache with the artifacts of clean builds. Developers will just pull from the remote cache and push to a local build cache.

Hope this will help future users.

like image 161
Pravin Divraniya Avatar answered Nov 16 '22 00:11

Pravin Divraniya