Setting up the Citrix micro VPN SDKs for Xamarin


  1. Clone the Citrix MAM SDK repository.

     git clone https://github.com/citrix/citrix-mam-sdks.git
     <!--NeedCopy-->
    

    You can find the Citrix micro VPN NuGet packages for Xamarin in the following location: <path>/citrix-mam-sdks/xamarin

    This folder contains all the necessary NuGet libraries required to build apps using the Xamarin.Android(Native) and Xamarin.Forms frameworks using the Citrix MAM SDK.

  2. Alternatively, you can download the Citrix Xamarin MAM SDK zip file.

    Note: A Citrix developer account is required to download the zip file.

    Unzip the file MAM_SDK_for_Android_Xamarin_23.1.0.3.zip.

     unzip MAM_SDK_for_Android_Xamarin_23.1.0.3.zip -d MAM_SDK_for_Android_Xamarin_23.1.0.3
     <!--NeedCopy-->
    

    The unzipped folder will have the following directory structure:

    MAMSDK Directory Structure

  3. Add NuGet sources to your project to point to the Xamarin MAM SDK NuGet libraries.

    For a Xamarin.Android(Native) app, you only need to add the Xamarin.MAMSDK.Android NuGet source.

     nuget sources Add -Name Xamarin.MAMSDK.Android -Source <Path to the Xamarin MAM SDK>/NugetPackage/Android
     <!--NeedCopy-->
    

    For a Xamarin.Forms app, you need to add both the Xamarin.MAMSDK.Android and Xamarin.MAMSDK.Forms NuGet sources.

     nuget sources Add -Name Xamarin.MAMSDK.Android -Source <Path to the Xamarin MAM SDK>/NugetPackage/Android
     nuget sources Add -Name Xamarin.MAMSDK.Forms -Source <Path to the Xamarin MAM SDK>/NugetPackage/Forms
     <!--NeedCopy-->
    
  4. Change the DeX compiler to d8 in your Xamarin project.

    Add the element <AndroidDexTool>d8</AndroidDexTool> in the PropertyGroup nodes in your .csproj file.

     <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "><AndroidDexTool>d8</AndroidDexTool></PropertyGroup>
    
     <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "><AndroidDexTool>d8</AndroidDexTool></PropertyGroup>
     <!--NeedCopy-->
    
  5. Change the minSdkVersion and targetSdkVersion in your Androidmanifest.xml file.

     <uses-sdk android:minSdkVersion="24" android:targetSdkVersion="31" />
     <!--NeedCopy-->
    
  6. Add Citrix Xamarin NuGet packages in your Xamarin project and change the version to the latest Xamarin MAM SDK version number.

    If your app is using Xamarin.Android (Native) and not Xamarin.Forms, add the Citrix.Xamarin.Android.MAMSDK NuGet library to your packages.config file.

     <package id="Citrix.Xamarin.Android.MAMSDK" version="23.1.0.3" targetFramework="monoandroid10.0" />
     <!--NeedCopy-->
    

    If your app is using Xamarin.Forms, you must add both the Citrix.Xamarin.Android.MAMSDK and Citrix.Xamarin.Forms.MAMSDK packages to your .csproj file:

     <PackageReference Include="Citrix.Xamarin.Android.MAMSDK">
       <Version>23.1.0.3</Version>
     </PackageReference>
     <PackageReference Include="Citrix.Xamarin.Forms.MAMSDK">
       <Version>23.1.0.3</Version>
     </PackageReference>
     <!--NeedCopy-->
    
  7. Add your KeyStore details using the IDE or by editing your .csproj file.

    Expand for IDE instructions:

    1. Right-click the project and click Options.
    2. Expand Build and click Android Package Signing.
    3. Select the Sign the APK file using the following KeyStore details check box.
    4. Fill in your KeyStore details.

    Go to Project Options

    Add key details for debug build

    After you have completed the preceding step, perform the following:

    1. Change the Configuration to Release.
    2. Select the Sign the APK file using the following KeyStore details check box.
    3. Fill in your KeyStore details.

    Add key details for Release build

    Expand for source code:

    Add your KeyStore and key details to your .csproj file:

     <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "><AndroidKeyStore>True</AndroidKeyStore>
         <AndroidSigningKeyStore>/Users/****/Downloads/mycompany.keystore</AndroidSigningKeyStore>
         <AndroidSigningStorePass>*****</AndroidSigningStorePass>
         <AndroidSigningKeyAlias>*****</AndroidSigningKeyAlias>
         <AndroidSigningKeyPass>****</AndroidSigningKeyPass></PropertyGroup>
     <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "><AndroidKeyStore>True</AndroidKeyStore>
         <AndroidSigningKeyStore>/Users/****/Downloads/mycompany.keystore</AndroidSigningKeyStore>
         <AndroidSigningStorePass>*****</AndroidSigningStorePass>
         <AndroidSigningKeyAlias>*****</AndroidSigningKeyAlias>
         <AndroidSigningKeyPass>****</AndroidSigningKeyPass></PropertyGroup>
     <!--NeedCopy-->
    
  8. Change the Release build to include no debugging information.

    1. Right-click the main project and click Options.
    2. Expand Build and click Compiler.
    3. Set the Configuration to Release
    4. Set Debug Information to None.

    Remove debug info for Release build

  9. Set the build type to Release or Debug.

    Select build type

  10. Right-click the project and click Build or Rebuild.

    Wait for the build to complete successfully.

    Select build or rebuild

  11. Right-click the project and click Archive for Publishing.

    Select Archive for Publishing

  12. Right-click the archive and click Sign and Distribute.

    Select Sign and Distribute

  13. Select Ad-Hoc and click Next.

    Select Ad-Hoc

  14. Choose your signing option and click Next.

    Choose your signing option

  15. Click Publish.

    Click Publish

  16. Save the APK at your desired location. A window with the message Publishing Succeeded appears.

    Save your apk

    Publishing Succeeded

  17. Generate the MDX file corresponding to your Xamarin app’s APK file using the command-line utility managed-app-utility.jar.

    You must manually generate the MDX file from the APK you saved earlier. You can refer how to manually generate a MDX file in the following page: Generate and update an MDX file.

    Note: It is imperative to use the same KeyStore you signed your APK with, when generating the MDX file.

    Use the following command to generate the MDX file:

     java -jar <mamSdkLib path>/managed-app-utility.jar \
     wrap \
     -in <path to apk>/<apk name>.apk \
     -out <path to save mdx file>/<mdx name>.mdx \
     -appType sdkapp \
     -keystore <keyStorePath> \
     -storepass <keystorePassword> \
     -keyalias <keyAlias> \
     -keypass <keyPassword> \
     -storeUrl "https://play.google.com/store/apps/details?id=<sample.app.package.name>"
     <!--NeedCopy-->
    
  18. To distribute your app, see the following page: Distribute your app.

  19. To test and debug your app, see the following pages:

Setting up the Citrix micro VPN SDKs for Xamarin

In this article