All Products
Search
Document Center

HTTPDNS:Android SDK version upgrade guide

Last Updated:Jun 23, 2026

Introduction

Use this guide to migrate your HTTPDNS Android SDK from an older version to the latest version. The guide covers:

  • Version compatibility overview: Compatibility between versions from 1.x to 2.6.x, so you can quickly identify incompatible upgrades.

  • Incompatible version upgrade guide: Upgrade steps, code examples, and old-to-new API mapping for each incompatible SDK version.

Version compatibility overview

The following table shows the compatibility between HTTPDNS Android SDK versions from 1.x.x to 2.6.x.

SDK version

Compatibility

1.x.x - 2.3.x

Fully compatible

2.3.5 - 2.4.0

Initialization interface adjusted

2.4.0 - 2.5.0

Fully compatible

2.5.0 - 2.6.6

API level upgraded (Android 4.4)

Guide to upgrading the SDK to version 2.4.0 or later

Version 2.4.0 is a major milestone that includes a complete architecture refactoring and interface optimization. Key changes:

  • Unified configuration pattern: Replaces scattered runtime configurations with a unified Builder-pattern initialization, resolving configuration timing issues and improving SDK stability.

  • Standardized resolution interfaces: Redesigned resolution interface with three patterns — synchronous blocking, asynchronous, and synchronous non-blocking — to cover different use cases.

  • Modular design: Features such as Log Management are separated into dedicated classes for better separation of responsibilities and maintainability.

  • Performance optimization: Improved resolution performance and resource utilization through interface and internal implementation enhancements.

This is a major, incompatible change. However, you only need to modify the interfaces that your application uses. Follow the upgrade steps and API mapping table below to complete the migration.

Detailed upgrade steps

  1. Update the dependency version

    dependencies {
        implementation 'com.aliyun.ams:alicloud-android-httpdns:${httpdnsVersion}'
    }
    Note

    You can obtain httpdnsVersion from the Android SDK Release Notes.

  2. Refactor the initialization code

    1. Before the upgrade

      // Old version: Scattered configuration
      HttpDnsService httpdns = HttpDns.getService(this, "your_account_id");
      
      httpdns.setHTTPSRequestEnabled(true);
      httpdns.setExpiredIPEnabled(true);
      httpdns.setCachedIPEnabled(true);
      httpdns.setPreResolveAfterNetworkChanged(true);
      httpdns.setTimeoutInterval(3000);
      httpdns.setLogEnabled(true);
      
      httpdns.setLogger(new ILogger() {
          @Override
          public void log(String message) {
              Log.d("HTTPDNS", message);
          }
      });
      
      httpdns.setDegradationFilter(new DegradationFilter() {
              @Override
              public boolean shouldDegradeHttpDNS(String host) {
                  return "example.com".equals(host);
              }
       });
      
      // If you use the IP ranking feature
      List<IPRankingBean> ipProbeList = new ArrayList<>();
      ipProbeList.add(new IPRankingBean("example.com", 80));
      httpdns.setIPProbeList(ipProbeList);
      
    2. After the upgrade

      List<IPRankingBean> ipRankingList = new ArrayList<>();
      ipRankingList.add(new IPRankingBean("example.com", 80));
      
      // New version: Unified configuration with the Builder pattern
      InitConfig config = new InitConfig.Builder()
        .setContext(this)                           // Required
        .setEnableHttps(true)                       // Replaces setHTTPSRequestEnabled
        .setEnableExpiredIp(true)                   // Replaces setExpiredIPEnabled
        .setEnableCacheIp(true)                     // Replaces setCachedIPEnabled
        .setPreResolveAfterNetworkChanged(true)     // Replaces setPreResolveAfterNetworkChanged
        .setTimeoutMillis(3000)                     // Replaces setTimeoutInterval
        .setIPRankingList(ipRankingList)            // Replaces setIPProbeList
        .setNotUseHttpDnsFilter(new NotUseHttpDnsFilter() {
              @Override
              public boolean notUseHttpDns(String host) {
                  return "example.com".equals(host);
              }
          })
        .buildFor("your_account_id");
       
        HttpDnsService httpdns = HttpDns.getService("your_account_id", config);
              
        // Log Management is now separate
        HttpDnsLog.enable(true);                        // Replaces setLogEnabled
        HttpDnsLog.setLogger(new ILogger() {            // Replaces setLogger
          @Override
          public void log(String message) {
            Log.d("HTTPDNS", message);
          }
        });
      }
      }
  3. Update the resolution interfaces

    1. Before the upgrade

      // Synchronous non-blocking, IPv4, single IP
      String ip = httpdns.getIpByHostAsync(host);
      // Synchronous non-blocking, IPv4, all IPs
      String[ ] ips = httpdns.getIpsByHostAsync(host);
      // Synchronous non-blocking, IPv6, single IP
      String ipv6 = httpdns.getIPv6ByHostAsync(host);
      // Synchronous non-blocking, IPv4 and IPv6, all IPs
      HTTPDNSResult result = httpdns.getAllByHostAsync(host);     
    2. After the upgrade

      // Synchronous non-blocking, IPv4, all IPs
      HTTPDNSResult httpDnsResult = httpdns.getHttpDnsResultForHostSyncNonBlocking(host, RequestIpType.v4)
      String[ ] ips = httpDnsResult.getIps();
      
      // Synchronous non-blocking, IPv6, all IPs
      HTTPDNSResult httpDnsResult = httpdns.getHttpDnsResultForHostSyncNonBlocking(host, RequestIpType.v6)
      String[ ] ipv6s = httpDnsResult.getIpv6s();
      
      // Synchronous non-blocking, IPv4 and IPv6, all IPs
      HTTPDNSResult httpDnsResult = httpdns.getHttpDnsResultForHostSyncNonBlocking(host, RequestIpType.v6)
      String[ ] ips = httpDnsResult.getIps();
      String[ ] ipv6s = httpDnsResult.getIpv6s();
  4. Upgrade the interface for setting the HTTPDNS blacklist

    1. Before the upgrade

      InitConfig config = new InitConfig.Builder()
          .setDegradationFilter(new DegradationFilter() {
              @Override
              public boolean shouldDegradeHttpDNS(String host) {
                  return "example.com".equals(host);
              }
          })
          .build();
    2. After the upgrade

      InitConfig config = new InitConfig.Builder()
          .setNotUseHttpDnsFilter(new NotUseHttpDnsFilter() {
              @Override
              public boolean notUseHttpDns(String host) {
                  return "example.com".equals(host);
              }
          })
          .build();
Note

If your application does not use any incompatible APIs, you can skip these steps.

API upgrade mapping table

API categorization

Before upgrade

After upgrade

Enable HTTPS request

HttpDnsService.setHTTPSRequestEnabled(boolean)

InitConfig.Builder.setEnableHttps(boolean)

Enable expired IP

HttpDnsService.setExpiredIPEnabled(boolean)

InitConfig.Builder.setEnableExpiredIp(boolean)

Enable local cache

HttpDnsService.setCachedIPEnabled(boolean)

InitConfig.Builder.setEnableCacheIp(boolean)

Pre-resolve on network transition

HttpDnsService.setPreResolveAfterNetworkChanged(boolean)

InitConfig.Builder.setPreResolveAfterNetworkChanged(boolean)

Set resolution timeout

HttpDnsService.setTimeoutInterval(int)

InitConfig.Builder.setTimeoutMillis(int)

Enable IP ranking feature

HttpDnsService.setIPRankingList(List<IPRankingBean>)

InitConfig.Builder.setIPRankingList(List<IPRankingBean>)

Set global parameters for custom resolution

HttpDnsService.setSdnsGlobalParams(Map<String, String>)

InitConfig.Builder.setSdnsGlobalParams(Map<String, String>)

Control log output

HttpDnsService.setLogEnabled(boolean)

HttpDnsLog.enable(boolean)

Set log callback interface

HttpDnsService.setLogger(ILogger)

HttpDnsLog.setLogger(ILogger)

Enable IP ranking (old version)

HttpDnsService.setIPProbeList(List<IPRankingBean>)

InitConfig.Builder.setIPRankingList(List<IPRankingBean>)

Synchronous non-blocking interface, IPv4 resolution, returns a single IP

getIpByHostAsync(String)

getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType.v4)

Synchronous non-blocking interface, IPv4 resolution, returns a list of IPs

getIpsByHostAsync(String)

getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType.v4)

Synchronous non-blocking interface, IPv6 resolution, returns a single IP

getIPv6ByHostAsync(String)

getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType.v6)

Synchronous non-blocking interface, IPv6 resolution, returns a list of IPs

getIPv6sByHostAsync(String)

getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType.v6)

Synchronous non-blocking, IPv4 and IPv6 resolution, returns a list of IPs

getAllByHostAsync(String)

getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType.both)

Synchronous non-blocking interface, custom resolution, returns a list of IPv4 addresses

getIpsByHostAsync(String, Map<String,String>, String)

getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType, Map<String, String>, String)

Synchronous non-blocking, custom resolution, returns a list of IPv4 addresses

getHttpDnsResultForHostAsync(String, Map<String, String> , String)

getHttpDnsResultForHostSyncNonBlocking(String, RequestIpType, Map<String, String>, String)

Summary

Version 2.4.0 introduced incompatible API changes. Follow the migration steps and API mapping table in this guide to upgrade your HTTPDNS Android SDK safely and efficiently.