Optimize the HERE SDK

This optimization guide lists several options to shrink the size of the HERE SDK and to optimize the runtime behavior by reducing the data that needs to loaded or processed.

Use the feature configuration

By setting a LayerConfiguration you can specify how much map data should be loaded into the cache when panning the MapView or when downloading a new Region for offline usage. For example, if a feature like turn-by-turn navigation is never used in an application, then the feature configuration navigation can be removed.

As a result, when panning the MapView less data will be downloaded into the cache. In addition, when downloading a new Region, its size will be smaller.

If a LayerConfiguration is set as list of Feature items via SDKOptions.layerConfiguration, then only the listed features will be enabled, all others will be disabled. If you want to disable only one feature, then all other features need to be present, or they will be also disabled.

For example, if the feature list contains navigation and TRUCK, then it enables only navigation and truck features and disables all others.

Only the LayerConfiguration will be used that was set globally when a Region was downloaded or cached for the first time. If you want to update the LayerConfiguration for an already downloaded region, delete the region and download it again - or call mapUpdater.performFeatureUpdate() (see also below).

As of now, the below features can be specified. The table also shows which features are enabled, by default:

Feature Enabled Description
detailRendering Yes Additional rendering details like buildings. Only used for the MapView. When not set, the data will be excluded when downloading offline regions or prefetching areas that contain such data. However, during online usage such data may still be downloaded into the cache and shown.
navigation Yes Map data that is used for map matching during navigation. When not set, navigation may not work properly when being used online or offline.
offlineSearch Yes Map data that is used to search. When not set, the OfflineSearchEngine may not work properly when being used.
offlineRouting Yes Map data that is used to calculate routes. When not set, the OfflineRoutingEngine may not work properly when being used.
truck Yes Map data that is used to calculate truck routes. When not set, the OfflineRoutingEngine may not work properly when being used to calculate truck routes. It is also used for map matching during truck navigation. When not set, truck navigation may not work properly when being used offline. Online truck navigation will still work when the device has an online connection.
landmarks3d No Map data that is used to render textured 3D landmarks. When not set, the data will be excluded when downloading offline regions or prefetching areas that contain such data. When the LANDMARKS layer is set to be visible for a MapScene, 3D landmarks will still be visible during online usage.
junctionView3x4, junctionView16x9 No 3D visuals for complex junctions. This asset data can be used to show SVG images during guidance. If enabled, downloaded regions will include junction view images to be used with the corresponding JunctionViewWarning event. This could be useful to download the assets before starting a trip. If not enabled, the required data will be downloaded when needed. Each image can occupy up to 15 MB. Note that future releases of the HERE SDK will optimize the size by reducing the level of realism. By default, the layer is not enabled.
junctionSign3X4, junctionSign4X3, junctionSign3X5, junctionSign5X3, junctionSign16X9 No Signpost visuals. This asset data can be used to show SVG images during guidance. If enabled, downloaded regions will include junction view images to be used with the corresponding SignpostWarning event. If not enabled, the required data will be downloaded when needed. Each image can occupy up to 300 KB. If not enabled, the required data will be downloaded when needed. By default, the layer is not enabled.
rendering Yes A basic set of rendering features such as carto POIs. As a base layer, this feature cannot be disabled.
traffic Yes Map data that provides traffic broadcast functionality using RDS-TMC format. It should be used when there is no internet connection, so that the routing module can utilize traffic data coming over the radio channel to create routes with the OfflineRoutingEngine.
ev No Offline map data for EV charging stations.
truckServiceAttributes No Enables truck related attributes to be returned by OfflineSearchEngine.
fuelStationAttributes No Enables fuel attributes to be returned by OfflineSearchEngine.
offlineBusRouting No Map data that is used to calculate bus routes. When not set, the OfflineRoutingEngine may not be able to calculate routes with BusOptions.
terrain No Map data that is used to represent topographical data.

Note that each of the listed features relates to one or more OCM layer groups. The names of the OCM layer groups can be seen per feature in the API Reference. However, for most use cases knowing the related OCM layer name is not relevant.

In addition, there are two layers, ADAS and EHORIZON (Electronic Horizon), that are currently not relevant for use with the HERE SDK editions and can be ignored for now. By default, they are already disabled.

If a feature is disabled, then it means that required data for that feature will not occupy space in the cache or as part of a Region download. It also means, that the feature cannot be used offline. And sometimes even an error may occur - for example, when trying to use the OfflineSearchEngine although offlineSearch has been disabled. Find more details below.

Note

Engines like the SearchEngine or the RoutingEngine will never make use of cached or downloaded map data. Only the OfflineSearchEngine and OfflineRoutingEngine will use such data if the related features have not been disabled. For example, if you are sure that your app fully operates online, it is safe to disable the offline search feature. However, if you want to ensure that an app can also search for POIs when there is a temporary connection loss, you may want to switch to the OfflineSearchEngine when such a loss is detected - and therefore, you should not disable the related feature.

As listed above, for some disabled features, a device may still download corresponding data when a device has online connectivity and the feature is needed. For example, when the landmarks3d feature is disabled, but the corresponding MapScene layer is enabled, then the device will still download the needed textures to render a 3D landmark when it becomes visible in the MapView viewport.

For all listed features from above - except for offlineSearch and offlineRouting, the HERE SDK will first check if the needed data is available in the cache. If not found there, it will look if there is a downloaded Region for offline use. If not found, the HERE SDK will try to download the needed data over the air. For offlineSearch and offlineRouting the behavior will be the same, but no data will be requested over the air.

Updating the feature configuration

Feature configurations can be updated after the installation of the next application update by calling mapUpdater.performFeatureUpdate(). Call this method once a feature configuration has been updated in the AndroidManifest/PList file.

As a result, the cached map data will be deleted and subsequently updated. Also, the downloaded regions will be updated to reflect the changes.

Note that it is the developer's responsibility to decide when to perform the update. The HERE SDK does not decide or notify when such an update can be made. Calling performFeatureUpdate() is only necessary once - after an application has been updated. It is not necessary to call this, when the feature configuration has not been changed by a developer.

Remove unused voices

By removing unused voice guidance files you can reduce the size of the HERE SDK.

These files are only needed when you want to use turn-by-turn navigation with text-to-speech voice messages.

Do the following to remove the unused files.

For Android:

  • Unzip the HERE SDK framework and search for the assets/voice_assets folder.
  • If you want to shrink the size of the framework, you can remove the voice packages you do not need.
  • Re-archive the AAR with Android Studio.

For iOS:

  • Inside heresdk.framework open the folder ios-arm64/voice_assets and remove the voice packages you do not need.

Here you can find a list of all supported voice languages together with the name of the related voice skin that is stored inside the HERE SDK framework.

Remove unused fonts

By removing unused fonts you can reduce the size of the HERE SDK. This is explained here.

ABI splits for Android

Size management: With ABI splits you can reduce the size of the HERE SDK AAR binary file. As a result, your application will occupy less storage space on a device.

By default, the HERE SDK includes the following ABIs for Android: armeabi-v7a, arm64-v8a (mainly used for devices) and x86, x86_64 (mainly used for emulators). You can enable ABI splits to build your app, for example, only for the armeabi-v7a or arm64-v8a architectures.

Do this by modifying your app's build.gradle file:

android {
  (...)
  splits {
    abi {
      enable true
      reset()
      include 'x86_64', 'arm64-v8a' // Choose what you need.
      universalApk false
    }
  }
  (...)
}

Now, when you execute ./gradlew assembleRelease from command line, the following two APKs are generated: app-x86_64-release.apk and app-arm64-v8a-release.apk. Each APK contains only the desired ABI and is therefore much smaller in size. If you change the splits block to set universalApk true, then also a universal APK is generated that contains all ABIs, which is obviously much bigger.

For more information about the splits Gradle block, see Configure Multiple APKs for ABIs.

Note

By default, an APK built with the HERE SDK for release will be around 103 MB or higher - depending on the app features. Therefore, in order to release an app the Play Store, it is required to use either ABI Splits or Android App Bundles (AAB): As of now, the Play Store limits APKs to 100 MB and for ABBs the limit is 150 MB. If you do not want to maintain several APKs built via ABI splits for selected architectures, consider to use ABBs instead.

Fat binary on iOS

The HERE SDK framework for iOS is a fat binary, built for device (arm64) and simulator (x86_64). Therefore it contains both architectures. This allows easy deployment on a simulator and on a real device. It also contains debug symbols to symbolicate crashes in Xcode.

Since the HERE SDK framework conforms to Apple's XCFramework bundle type (XCFW), it is ready to be used for the distribution of your app. As it is the practice, in Xcode you have to select a development team to sign your app, select a Generic iOS Device and select Product -> Archive.

The binary size of an exported app (ie. resulting IPA) for a target device will occupy less space. Note that you can also manually remove files that are not required. However, please keep in mind that the IPA still contains all architectures - unless you explicitly excluded them when archiving: The actual size on the device will occupy much less space and Apple will ensure that only the required architectures are included. Thus, also the actual download size from the App Store will be much smaller. See also this Xcode guide. Therefore, we recommend to keep the HERE SDK framework as it is when the app is deployed through the App Store - since all size optimization happens automatically as part of the deployment process.

More options

Other options to optimize the HERE SDK include:

In addition, all engines contain several options that allow how to configure a feature. For example, when using the SearchEngine, you can specify SearchOptions to limit the returned search results.

results matching ""

    No results matching ""