ArcGIS Runtime SDK for .NET

Deploy your app

Apps built with ArcGIS Runtime SDK for .NET require an ArcGIS Runtime deployment. The ArcGIS Runtime deployment contains the minimum set of ArcGIS Runtime components required to support the functionality in your app, from rendering beautiful maps to performing complex GIS analysis. Likewise, excluding unneeded components produces focused apps with a smaller footprint, containing bits only for the capabilities you need.

Define ArcGIS Runtime components to deploy

If you've created a deployment for a version 10.2.x ArcGIS Runtime app then you're familiar with the ArcGIS Runtime .NET Deployment Manifest file and perhaps the Visual Studio UI that was available for selecting the runtime components you needed in your deployment. At version 100.x of ArcGIS Runtime SDK for .NET, you no longer use a manifest file to configure your standard runtime deployment. In fact, at version 100.0 and later all you need to do is, well .... nothing. An ArcGIS Runtime deployment is now created for you automatically when you build your project.

The ArcGIS Runtime SDK for .NET NuGet package(s) you add to your project will deploy the necessary runtime components according to your build configuration. If you're building a WPF project for both 32 and 64 bit platforms, for example, ArcGIS Runtime deployments will be created in directories called client32 and client64. These directories appear under a folder called ArcGISRuntime100.x in the project output folder (bin/Debug or bin/Release, for example).

Deployment folder for ArcGIS Runtime
Caution:

If you have a 10.2.x version of ArcGIS Runtime SDK for .NET installed, you will see the Add ArcGIS Runtime .NET Deployment Manifest menu choice in Visual Studio when working in your ArcGIS Runtime SDK for .NET version 100.x projects. You cannot use this manifest file to define your deployment package, however, and will receive an error ("Unsupported SDK version") when attempting to add the file.

You will require an ArcGIS Runtime deployment for every target platform for your app. The ArcGIS Runtime NuGet packages will automatically detect the build target for the project and build an ArcGIS Runtime with the appropriate architecture. This can be one or more of x86 (32 bit), x64 (64 bit), any CPU, or ARM depending on your app type.

Note:

Deployment steps may differ for each platform in ArcGIS Runtime SDK for .NET (WPF, Windows Universal, Android, iOS). Consult the deployment information for each platform you want to deploy.

Deploying specialized symbols

You may need to deploy specialized symbols, such as military symbol dictionaries, for use with your ArcGIS Runtime SDK app. In ArcGIS Runtime SDK for .NET versions prior to 100.0, these symbols were included in the SDK install and could simply be copied to a deployment folder for your app. To reduce the size of the setup (especially with the increased number of supported platforms), these symbols are not included in the ArcGIS Runtime SDK for .NET NuGet packages.

You have a couple of options for including these symbols in your deployment.

  1. Download the .stylx files from ArcGIS Online. The ArcGIS for Defense group hosts the following ArcGIS Online items that contain .stylx files with military symbols. Once downloaded, you can include the files in your app deployment. Logic in your app, of course, would be required to locate and use the files as needed.
  2. Add logic to your app that prepares the app for offline use by downloading the files and storing them locally. You can access these resources when your user is online either by programmatically downloading them (using System.Net.Http.HttpClient, for example) or accessing them as portal items using the ArcGIS Runtime API, reading their contents, and storing them locally. The following example shows how to access the military symbol items listed above using ArcGIS Runtime code.
// Get the ArcGIS Online portal (default if no URI is provided)
ArcGISPortal agol = await ArcGISPortal.CreateAsync();

// Get the military symbol items (use their unique item IDs)
PortalItem itemMil2525c = await PortalItem.CreateAsync(agol, "5190cc905bff4ecda122d5e0c69ddeda");
PortalItem itemMilStd2525d = await PortalItem.CreateAsync(agol, "e34835bf5ec5430da7cf16bb8c0b075c");

// Read the data from the items
var dataMil2525c = await itemMil2525c.GetDataAsync();
var dataMilStd2525d = await itemMilStd2525d.GetDataAsync();

// ... Code here to read the data and write it to a local file ...

Reducing your APK size

An Android Package (APK) is a compressed package file format used by the Android operating system to install applications on mobile devices. The internal packaged contents of the APK file can be viewed in a zip/unzip compression application like: WinZip, 7-Zip, WinRAR, etc. As per Google, to deploy a custom APK file on the Google Play Store, the APK must remain below 100 MB in size. Keeping a custom APK below 100 MB requires a few considerations when developing an ArcGIS Runtime application via Visual Studio with Xamarin.

First, Android supports a few different instruction set architectures. It is possible to bundle multiple platform architectures into a single APK. The more architectures added to the APK, the larger the APK will be. It is recommended to limit each APK to a single architecture.

The Android architectures available in Visual Studio with Xamarin are: armeabi, armeabi-v7a, x86, x86_64, and arm64-v8a. To change which Android architectures are available when creating a deployable APK in Visual Studio, click the Project > [ProjectName] Properties… menus to open the project properties tab. Then click on the Android Options in the side bar, scroll towards the bottom and click the Advanced button to open the Advanced Android Options dialog.

Finding the Visual Studio Project Properties Android Options Tab's Advanced Button

In the Advanced Android Options dialog, click the Supported architectures dropdown and choose which architecture(s) will be generated for the APK. Again it is recommended to choose only one architecture per APK to limit its size.

Setting the Supported Architecture in Visual Studio Advanced Android Options Dialog

Second, whenever functionality is added to an application, the APK size increases because of the dependent assemblies that are required for that functionality. Therefore creating an application that consumes the ArcGIS Runtime binaries (ex: Esri.ArcGISRuntime.dll, Esri.ArcGISRuntime.Hydrography.dll, Esri.ArcGISRuntime.Xamarin.Forms.dll, and others) will increase the size of the APK. Plus there could be assemblies from other 3rd party binaries that increase the APK size. For example creating a simple mapping application that uses the MapView control to display a base map layer (which requires adding the Esri.ArcGISRuntime.dll) to create an Android APK could result in exceeding the 100 MB size limit for the Google Play Store.

Fortunately, the Microsoft Visual Studio with Xamarin compiler has options to decrease the size of the APK based upon the actual functionality that is used from a particular assembly linking. Linking allows the Visual Studio with Xamarin compiler to shrink the size of the dependency binaries placed in the APK to only those pieces of functionality that are needed. There are several options that can be chosen when compiling APK that are well documented by Microsoft in the Linking on Android document. In tests performed by the ArcGIS Runtime for .NET team, excellent success can be achieved in minimizing the size of the APK by choosing the 'Sdk Assemblies Only' option in the Linking section of the Project properties pane.

Setting the Linking Option in the Visual Studio Project Properties Android Options Tab

Other APK considerations

  • When defining when architecture to use for creating Android APKs, it should be noted that x86 and x86_64 versions should not be used for Google Play Store deployments. These architectures are for testing and debugging the device emulators on the PC.
  • Google has specific recommendations for creating APKs in the Android Developers Blog.
  • To deploy an APK for use on the Google Play Store or to side-load onto a device/emulator, right click on the project name in the Visual Studio Solution Explorer pane and choose Archive… This will automatically start process of generating an APK file.Creating a Deployable Android APK File Using the Visual Studio Solution Explorer's Archive Option
  • Remember to use the Release build option to create smaller binaries. The Debug build option will be much larger and have slower execution time.
  • Here is a tip on how to side-load an APK onto a Windows device emulator:

    -- Start the emulator of choice by using the Visual Studio menus of: Tools > Android > Android Device Manager…

    -- Open a ‘Developer Command from for Visual Studio’ and navigate to where your Android SDK platform tools are installed (ex: C:\Program Files (x86)\Andorid\android-sdk\platform-tools).

    -- Type ‘adb devices’ to connect to the running emulator. You should see ‘List of devices attached’ and ‘emulator-XXXX device’, where XXXX is the device number that is running.

    -- Type ‘adb install “[PathAndFileNameOfTheAPK]”’ to side-load the APK onto the emulator. For example “[PathAndFileNameOfTheAPK]” could be something like “C:\MyApps\MyAndroidMapApp\release\MyAndroidMapApp-Signed.apk”.