HERE SDK cannot resolve hostnames due to invalid DNS settings (Override System DNS with NetworkSettings)

HERE SDK cannot resolve hostnames due to invalid DNS settings (Override System DNS with NetworkSettings)
------------------------------------------------------------------------------------------------------------

Symptoms / Triggers
-----------------------

You may experience one or more of the following symptoms when initializing or using the HERE SDK:

HERE SDK cannot connect to backend services.
Network requests fail despite an active internet connection.
Hostnames cannot be resolved due to incorrect or blocked DNS configuration.
The device or network environment uses an invalid DNS server.
Corporate or custom network settings interfere with DNS resolution.

Quick Answer
----------------

If the system DNS configuration is invalid or blocked, you can use the HERE SDK NetworkSettings class to specify custom DNS servers. Set the domainNameSystemServers property before creating the SDKNativeEngine. This overrides the SDK's default DNS detection mechanism.

Step-by-Step Details

1. Create the HERE SDK authentication configuration

String accessKeyID = BuildConfig.HERE_ACCESS_KEY_ID;

String accessKeySecret = BuildConfig.HERE_ACCESS_KEY_SECRET;

AuthenticationMode authenticationMode =

AuthenticationMode.withKeySecret(

accessKeyID,

accessKeySecret);

SDKOptions options = new SDKOptions(authenticationMode);

2. Configure a custom DNS server

Create a NetworkEndpoint for the DNS server you want the SDK to use:

InetSocketAddress dnsAddress =

new InetSocketAddress("8.8.8.8", 53);

NetworkEndpoint networkEndpoint =

new NetworkEndpoint(dnsAddress.getAddress());

List dnsServers =

List.of(networkEndpoint);

3. Configure NetworkSettings

NetworkSettings networkSettings =

new NetworkSettings();

networkSettings.domainNameSystemServers =

dnsServers;

options.networkSettings = networkSettings;

4. Initialize the SDK

try {<br /><br />SDKNativeEngine.makeSharedInstance(<br /><br />this,<br /><br />options);<br /><br />} catch (InstantiationErrorException e) {<br /><br />throw new RuntimeException(<br /><br />"Initialization failed: "<br /><br />+ e.error.name());<br /><br />}

### Important Considerations

The domainNameSystemServers list completely replaces the SDK's embedded DNS detection mechanism.
The order of DNS servers is important. Place the preferred DNS server first.
Only IPv4 DNS servers are currently supported.
DNS settings must be configured before creating the SDKNativeEngine.
A common use case is overriding an invalid system DNS configuration that prevents the SDK from accessing HERE services.

Related Documentation

HERE SDK NetworkSettings
HERE SDK domainNameSystemServers
* HERE SDK SDKOptions.networkSettings

Searchable Tags / Keywords
------------------------------

HERE SDK, NetworkSettings, DNS, domainNameSystemServers, SDKNativeEngine, hostname resolution, custom DNS, override system DNS, Android, Java, network connectivity, DNS configuration, DNS troubleshooting, 8.8.8.8, NetworkEndpoint.

Demo of using NetworkSettings to utilize DNS 8.8.8.8 to override a invalid system DNS which blocks all internet traffic:


Did this page help you?