Android SDK Overview | 2GIS Documentation

Android SDK

Android SDK is an SDK that allows you to add a 2GIS map to your Android application. It can be used to display the map in your layout, add custom markers to it, draw geometric shapes, calculate and display routes, get information about map objects, control the camera movement, and so on.

You can find usage examples in the Examples section. For a detailed description of all classes and methods, see API Reference.

Geodata complies with OGC standards.

To work with MobileSDK, you need to get the key file dgissdk.key with the obligatory indication of the appId of the application for which this key is created. This key will be used to connect to 2GIS servers and retrieve the geographical data, as well as to use offline and the navigator. This key is unique to the SDK and cannot be used with other 2GIS SDKs.

To obtain this key file:

  1. Fill in the form at dev.2gis.com.
  2. Add the resulting key file to the assets of the application.

When the key is activated, you can sign in to the Platform Manager and check statistics of request distribution.

Android SDK is distributed in two versions: full and lite. The lite version does not include the routes and navigation functionality.

To install the SDK:

  1. Declare a custom repository in your build.gradle file.
repositories {
    maven {
        url "http://artifactory.2gis.dev/sdk-maven-release"
    }
}
  1. Add one of the following build dependencies.

To get the lite version of the SDK:

dependencies {
    implementation 'ru.dgis.sdk:sdk-map:latest.release'
}

To get the full version of the SDK:

dependencies {
    implementation 'ru.dgis.sdk:sdk-full:latest.release'
}

You can find a demo app with the source code in our GitHub repository.

The size of your application may increase noticeably after adding the SDK to your project. Let's look at the cause and possible strategies for dealing with this increase.

Modern Android devices can have different types of processors - x86, x86_64, armv7, and armv8. For code written in Java or Kotlin, this is not an issue as it is executed in a virtual machine and abstracted from the specific hardware. However, for native code, processor type plays an important role.

Therefore, our library contains 4 versions for all ABI (Application Binary Interface) types to provide support for all these processor types.

To reduce the size of your application, you can use splitting APKs by ABI type. This will ensure that only the necessary libraries for a user's specific device are built and loaded. Instructions on how to do this can be found in the Android documentation. Also, if you are using App Bundle, Google Play can automatically rebuild the app for the right processor types for specific user devices.

To see the actual size of the APK that will be downloaded by the user, we recommend using the bundletool tool. This will help to get an APK containing only the required libraries for a particular device.

Steps:

  1. Build app bundle, for this you need to select this build option in Gradle.
  2. From app bundle, use bundletool to get apk with necessary criteria (for example, only for arm64-v8a).

The resulting apk will reflect the real size the user will get when downloading the app from Google Play.