Configure SonarQube in a Android Project using Docker
Tags: codequality, android, sonarqube
Published: 2024-01-21 05:25:52

---
title: Configure SonarQube in a Android Project using Docker
published: true
date: 2022-08-25 18:19:12 UTC
tags: codequality,android,sonarqube
canonical_url: https://medium.com/@lahirujay/configure-sonarqube-in-a-android-project-using-docker-f437da0a6418
---

Hey everyone,

This is a step-by-step guide for integrating SonarQube for Android project using docker. Without any further delay, let’s dive right in.

#### **What is SonarQube?**

According to the official documentation,

> “SonarQube is an automatic code review tool to detect bugs, vulnerabilities, and code smells in your code.”

#### **What is Docker?**

Docker simplifies the process of developing applications. It provides a set of tools that allow developers to create, test and deploy applications in loosely isolated environments.

#### **Prerequisites**

>  Docker ([https://cutt.ly/WG4feRX](https://cutt.ly/WG4feRX))  
>  Android Development Environment

#### **Starting SonarQube**

Start the Docker engine and log in to your account. Next, Install the SonarQube image and run it with the below command in the terminal.

![](https://cdn-images-1.medium.com/max/994/1*qnYnRMhwLxdB9uhRT50gJQ.png)

With this, it will print the container ID once SonarQube is up and running successfully. To access it: “[http://localhost:9000/](http://localhost:9000/)”. The default user and password is “admin”

#### **Configure a SonarQube Project.**

Once you logged in to your SonarQube instance. Select the project creation option as “_Manually_” to run the scan from your local codebase.

![](https://cdn-images-1.medium.com/max/1024/1*q2w3NqI-2bUkXaP8fO_f9Q.png)

To set up the project provide a Display Name and Project Key.

![](https://cdn-images-1.medium.com/max/1024/1*PHsY11o59Q8YaNyruVGpZQ.png)

Next, provide “_Locally_” as the way you want to analyse your repository.

![](https://cdn-images-1.medium.com/max/1024/1*hW9UAtAYqI2oIIMqWOg8Dw.png)

To authenticate the user to perform the analysis, generate the token by providing a name

![](https://cdn-images-1.medium.com/max/1024/1*mQmeQ4pH5bZggM3-zMUNJg.png)

#### **Performing an analysis**

Add the sonar scanner plugin in your Project level Gradle.

![](https://cdn-images-1.medium.com/max/1024/1*9H2WknP0TmlMqR6XXRYt_g.png)

Next, in your App level Gradle configure as below

![](https://cdn-images-1.medium.com/max/1024/1*KAF69JuMqpYXgDrBHrZYMw.png)

Replace the _PROJECT-NAME, PROJECT-KEY,_ and _TOKEN_ with the generated and provided values in the previous steps. Inclusion and exclusion depend on your requirement.

Sync your Gradle and run the following command on your terminal.

![](https://cdn-images-1.medium.com/max/504/1*Ox-xr37H0m5d3z0OuU2O7g.png)

After the build is successful access your project at “[http://localhost:9000/projects](http://localhost:9000/projects)” to view your project report

![](https://cdn-images-1.medium.com/max/1024/1*HIwbljjok71XfHUluv-D2w.png)

That’s it. Now you can review your project and improve your code quality. But this is a basic SonarQube Android setup. There are a lot of things you can do with SonarQube. Learn it, research it & share it. I hope you found this useful. Until next time 🙏 👋