Android Xamarin App- Sign your app using a keystore in a Release Pipeline

keystore secure file uploaded

To sign your Xamarin Android app using Visual Studio, you can use the keystore setings in the project properties. This will generate a jks file for Windows.

See Compile steps: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/?tabs=windows#compile

Then continue to these steps to export the JKS file: https://docs.microsoft.com/en-us/xamarin/android/deploy-test/signing/?tabs=windows

Once you export the app, you can copy the file: C:\Users\EricSchrader\AppData\Local\Xamarin\Mono for Android\Keystore\DevOps

android xamarin keystore file

 

Click Secure Files in Azure DevOps pipeline for your project:

azure devops secure file tab

Select your keystore file

pick keystore file

Now you can upload the keystore file to Azure DevOps Pipeline:

keystore secure file uploaded

Then you can update the build pipeline to use the keystore file and password (password stored in Library variable for security)

add build with keystore

 

Then simply run the build and grant access to the Variables group.

Azure App Center- Android Xamarin test run error on Windows fix

Microsoft Azure App Center appcenter test run uitest

There are quite a few steps to run apps on the App Center while configuring Test Runs in Xamarin.

First, install the following:

  1. Android SDK https://developer.android.com/studio
  2. Visual Studio 2019 with the Xamarin addon in the Visual Studio Installer:
    1. visual studio xamarin install
  3. Java SDK http://java.sun.com/javase/downloads/index.jsp

Once everything was installed, I restarted my command prompt, opened my Xamarin Android app project in VS and did a Debug build to demo the app. Once I did this, that triggered the build for the APK file.

Then I do the commands the over in the web browser Microsoft App Center (https://appcenter.ms), but I add a bug fix parameter to the end of the Running Tests command (–uitest with path).

Microsoft Azure App Center appcenter test run uitest

appcenter login

appcenter test run uitest --app "DevOps-Training-1/Android-xamarin" --devices "DevOps-Training-1/both" --app-path C:\vs\MobileDevOps\MobileDevOps\bin\Debug\com.companyname.MobileDevOps.apk --test-series "master" --locale "en_US" --build-dir C:\vs\MobileDevOps\UIAndroidTest\bin\Debug --uitest-tools-dir C:\Users\EricSchrader\.nuget\packages\xamarin.uitest\3.0.3\tools

You will get an ANDOID_HOME error,

(No path) - Not set. [ Source: ANDROID_HOME ]

Then, set theĀ ANDOID_HOME Windows Android SDK location (make sure you replace the user desktop account with your current user path)

set JAVA_HOME=C:\Users\EricSchrader\AppData\Local\Android\Sdk
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

 

That should get you to the next error, JAVA_HOME.

If you see this error:

Java Development Kit (JDK) not found. Please make sure that it is installed and if it's still not located, please set the JAVA_HOME environment variable to point to the directory.

Then, set the JAVA_HOME path (and make sure your JDK version matches)

  • Overview: https://docs.oracle.com/cd/E19182-01/821-0917/inst_jdk_javahome_t/index.html
  • Actual commands I used (NOTE YOUR VERSION and make sure that path exists, otherwise replace with your jdk- version number)
set JAVA_HOME=C:\Program Files\Java\jdk-14.0.2
set PATH=%PATH%;%JAVA_HOME%\bin

Once all is done, the app test will be submitted and complete without issues:

app center andoid xamarin

 

Check out Donovan Browns post as well for an alternative way of doing this in VS. I was using CMDer, https://www.donovanbrown.com/post/Migrating-from-Xamarin-Test-Cloud-to-App-Center-Test