Master Android CI/CD: Step-by-Step Jenkins Setup and Common Pitfalls

This guide walks you through configuring Jenkins on a CentOS 6.3 server to automatically compile Android projects from a GitLab repository, covering environment preparation, Jenkins installation, job creation, Gradle integration, and troubleshooting common issues such as SDK updates, permission errors, and memory limits.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Android CI/CD: Step-by-Step Jenkins Setup and Common Pitfalls

1. Related Environment

Operating system: Linux CentOS 6.3 (2.6.32-279.el6.x86_64). Install the required software versions as shown in the accompanying screenshots.

Update the Android SDK:

Run tools/android update sdk --no-ui (ensure at least 6 GB of free disk space).

Because the build uses build-tools 22.0.1, install that specific version:

List all available packages: android list sdk --all and locate the build‑tools entry (code 8).

Install it with android update sdk --no-ui --all --filter 8.

Check installed targets with android list target.

2. Install Jenkins

Download and install Jenkins on the same CentOS machine (see the screenshot for the installation process).

3. Jenkins Startup and Initial Configuration

Access Jenkins at http://localhost:8080. If the page is unreachable, disable the firewall (iptables) for testing.

First login requires unlocking Jenkins with a secret file generated on the host.

Proceed with the default plugin installation; after the plugins are installed, the main dashboard appears.

4. Create a Build Job

Select Freestyle project as the job type.

Configure Source Code Management:

Choose Git and provide the GitLab repository URL.

If the Git option is missing, reinstall the Git plugin.

Set up GitLab credentials (the process may require several attempts).

Build Triggers:

Jenkins can be linked to GitLab webhooks, but for simplicity use SCM polling every 5 minutes (cron expression H/5 * * * *).

Explanation of cron fields: minute (0‑59), hour (0‑23), day of month (1‑31), month (1‑12), day of week (0‑7, where 0 and 7 are Sunday).

Build Step:

Add Invoke Gradle script and select the Gradle version you installed earlier (do not use the default).

5. Common Jenkins‑SDK Pitfalls

Gradle not found: Ensure the Gradle installation path is correctly set in Global Tool Configuration and select the proper version in the job.

Permission errors: If Gradle is extracted to /root, Jenkins runs as its own user and may lack access. Place Gradle in a directory readable by the Jenkins user.

Missing Git: Install Git 2.7+ from source and configure its path in Jenkins system settings.

HTTP connection failures: Verify network connectivity and proxy settings.

Java OutOfMemoryError: Increase JVM heap size, e.g., export JAVA_OPTS="-Xms1024m -Xmx1024m".

6. Required Libraries

libstdc++‑4.4.7‑17.el6.i686

zlib‑1.2.3‑29.el6.i686

zlib‑devel (development headers)

After configuring the job, click Build Now . A blue ball indicates a successful build, while a red ball signals failure. The generated APK is placed in the build/outputs directory of the workspace and can be copied elsewhere as needed.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ci/cdAndroidGitLabGradleJenkinsCentOS
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.