Compile and package an Android application
Using Codefresh pipelines
Android applications are using Java/Gradle for their build system. Because Codefresh already supports Gradle it is also very easy to build Android projects.
Any Gradle command can run inside a Docker image that contains the Android SDK. As an example we will use a Nextcloud image from Dockerhub.
The example project
You can see the example project at https://github.com/codefresh-contrib/android-sample-app. The repository contains a Hello World Android project with the following tasks.
./gradlew testruns unit tests
./gradlew buildbuilds the application
Create a CI pipeline that compiles/releases Android
In most cases you would create a similar pipeline to a Gradle project.
Here is the full pipeline that uses a Docker image with the Android SDK in order to run Gradle.
This pipeline clones the source code, runs unit tests and finally builds the Android application.
Codefresh is smart enough that caches automatically for us the workspace of a build (
/codefresh/volume). This works great for build tools that keep their cache in the project folder, but not for Maven/Gradle which keep their cache externally. By changing the location of the Gradle cache we make sure that Codefresh will cache automatically the Gradle libraries resulting in much faster builds.