Skip to content

Commit 87236db

Browse files
committed
android build docs
1 parent 1b03da3 commit 87236db

8 files changed

Lines changed: 100 additions & 0 deletions
50.9 KB
Loading
52.6 KB
Loading
25.5 KB
Loading
51.9 KB
Loading
24.7 KB
Loading
58 KB
Loading
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Xamarin Android Build
2+
3+
Follow these steps to create a VSTS build for your eShopOnContainers app.
4+
5+
**Note**: This document assumes basic knowledge about creating builds and configuring external VSTS connections
6+
7+
## Creating the build
8+
9+
Despite the _"Get Sources"_ task there are five tasks more in the build:
10+
11+
1. Restore NuGet Packages
12+
2. Build Xamarin Android Project
13+
3. Download the certstore to sign the APK
14+
4. Sign the APK
15+
5. Publish the build artifact.
16+
17+
![Android Build Steps](images/android-build.png)
18+
19+
Let's discuss each of them.
20+
21+
### Restore NuGet Packages
22+
23+
Add a "NuGet restore" task and enter the following configuration:
24+
25+
1. Enter `eShopOnContainers-Android.sln` in "Path to solution, packages.config, or project.json". This sln is created ex professo for the build and contains only the Xamarin Android project plus the Xamarin Forms one.
26+
27+
![Android Build Step 1](images/android-build-step1.png)
28+
29+
### Build the project
30+
31+
Add a "Xamarin Android" task with following configuration:
32+
33+
1. `**/*Droid*.csproj` in "Project"
34+
2. `$(build.binariesdirectory)/$(BuildConfiguration)` in "Output Directory"
35+
3. `$(BuildConfiguration)` in "Configuration"
36+
4. Ensure that the "Create App Package" checkbox is enabled
37+
5. In "JDK Options" be sure to select "JDK 8" in the "JDK Version" dropdown.
38+
39+
![Android Build Step 2](images/android-build-step2.png)
40+
41+
### Download the keystore to sign the build
42+
43+
** Note** This require you have a valid keystore. Refer to [this Xamarin article](https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_2_-_signing_the_android_application_package/) for instructions on how create one, using Visual Studio and Xamarin. Or if you prefer, you can read [how use the Android SDK tools to create a keystore](https://developer.android.com/studio/publish/app-signing.html).
44+
45+
This build assumes the keystore is stored somewhere in internet. Beware on where you store your keystores! Keem them safe and privately. Always consider other possible alternatives on where store the keycert:
46+
47+
1. Store in the source control repository, **assuming it's private**. For public repositories this option is discarded
48+
2. Store in the build agent. If you use a custom VSTS build agent, store the keycert files locally in the agent. This is simple and secure.
49+
3. Store in internet. If this is the case, **protect the resource**. You can be forced to use this option if your repository is public *and* you use the VSTS hosted agent.
50+
51+
Add a task "Download file" (**Note:** this task is installed [through a VSTS extension](https://marketplace.visualstudio.com/items?itemName=automagically.DownloadFile)) with following configuration:
52+
53+
1. `$(keystore.url)$(keystore.name)` in "File URL"
54+
2. `$(Build.SourcesDirectory)` in "Destination Folder"
55+
56+
Fill the "Credentials" section accordly.
57+
58+
![Android Build Step 3](images/android-build-step3.png)
59+
60+
**Note:** You can, of course, use any other way to download the file (like a Powershell task).
61+
62+
### Signing the APK
63+
64+
Add a "Android Signing" task with following configuation:
65+
66+
1. `$(build.binariesdirectory)/$(BuildConfiguration)/*.apk` in "APK Files"
67+
2. Ensure the checkbox "Sign the APK" is checked
68+
3. `$(Build.SourcesDirectory)\$(keystore.name)` in "Keystore file". This location has to be where the keystore is. If you downloaded it using a previous task (as our example), use the same value. If keystore is physically in the VSTS agent you can use the filepath.
69+
4. `$(keystore.pwd)` in "Keystore Password"
70+
5. `$(keystore.alias)` in "Keystore Alias"
71+
6. `$(key.pwd)` in "Key password".
72+
7. `-verbose` in "Jarsigner Arguments"
73+
7. Ensure the checkbox "Zipalign" is checked.
74+
75+
![Android Build Step 4](images/android-build-step4.png)
76+
77+
### Publishing build artifact
78+
79+
Add a "Publish Build Artifacts" task, with following configuration:
80+
81+
1. `$(build.binariesdirectory)/$(BuildConfiguration)` in "Path to publish"
82+
2. `drop` in "Artifact Name"
83+
3. `Server` in "Artifact Type"
84+
85+
![Android Build Step 5](images/android-build-step5.png)
86+
87+
## Variables
88+
89+
You need to setup the following variables:
90+
91+
1. `keystore.pwd` -> Password of the keystore
92+
2. `keystore.alias` -> Alias of the keystore
93+
3. `keystore.url` -> Full URL of the keystore
94+
4. `key.pwd` -> Password of the key
95+

azure-docs/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Azure Related Documentation
2+
3+
## Builds and releases
4+
5+
1. [VSTS build for Xamarin App (Android)](builds/xamarin-android.md)

0 commit comments

Comments
 (0)