Build an Android Mobile Application Using Azure DevOps
As an introduction, use Azure DevOps to construct, build, and deploy a mobile app using Gradle.
Join the DZone community and get the full member experience.
Join For FreeThis post is as an introduction to Azure DevOps. If you are new to this, can check out a helpful DZone article here.
Use the azure-pipelines.yml file at the root of the repository. Get this file to build the Android application using a CI (Continuous Integration) build.
Follow the instructions in Create a build pipeline , https://dzone.com/articles/introduction-to-azure-pipelines to create a build pipeline for an Android application.
After creating a new build pipeline, you will be prompted to choose a repository. Select the Github/Azure Repository. Need to authorize the Azure DevOps service to connect to GitHub account, Click Authorize, this will integrate with your build pipeline.
After connection to GitHub has been authorized, select the right repo, which is used to build the application.
Steps
Azure pipelines have an option to build and deploy using a Microsoft-hosted agent. When running a build or release pipeline, get a fresh virtual machine (VM). If Microsoft-hosted agents will not work, use a self-hosted agent, as it will act as a build host.
pool:
name: Hosted VS2017
demands: java
- Build a mobile application using a Gradle wrapper script, check out the branch and repository of the gradlew wrapper script. The gradlew wrapper script is used for the build, if the agent is running on windows must use the gradlew.bat, if the agent runs on Linux or MacOs can use the gradlew shell script.
Set the current working directory and Gradle wrapperfile script directory.
steps:
- task: Gradle@2
displayName: 'gradlew assembleDebug'
inputs:
gradleWrapperFile: 'MobileApp/SourceCode -Android/gradlew'
workingDirectory: 'MobileApp/SourceCode -Android'
tasks: assembleDebug
publishJUnitResults: false
checkStyleRunAnalysis: true
findBugsRunAnalysis: true
pmdRunAnalysis: true
This task detects all open source components in your build, security vulnerabilities, scan libraries, and outdated libraries (including dependencies from the source code). You can view from the build level, project level, and account level.
task: whitesource.ws-bolt.bolt.wss.WhiteSource Bolt@18
displayName: 'WhiteSource Bolt'
inputs:
cwd: 'MobileApp/SourceCode -Android'
Copy the .apk file from source to the artifact directory.
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactStagingDirectory)'
inputs:
SourceFolder: 'MobileApp/SourceCode -Android'
Contents: '**/*.apk'
TargetFolder: '$(build.artifactStagingDirectory)'
Use this task in the build pipeline to publish the build artifacts to Azure pipelines and file share.it will store it in the Azure DevOps server.
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
The new pipeline wizard should recognize that you already have an azure-pipelines.yml in the root repository.
The azure-pipeline.yml file contains all the settings that the build service should use to build and test the application, as well as generate the output artifacts that will be used to deploy the app later release pipeline(CD).
After everything is perfect, save and queue the build so you can see the corresponding task of logs to the respective job.
After everything is done, extract the artifact zip folder, copy the .apk file into the mobile device and install the .apk file.
Opinions expressed by DZone contributors are their own.
Comments