LogoLogo
My AppsLive demoNewsArticles
  • Introduction
  • 📌Product updates: 2025
    • 2024
    • 2023
  • Getting Started
    • Registration
    • Adding a space
    • Adding an app to the space
  • Basic Events & Custom Events
  • Integration
    • Expert Tips
      • What to track
      • Payments & Anti-cheat
      • Check your integration
    • Integration of SDK 2.0+
      • SDK Integration
        • Android
        • iOS
        • macOS
        • Windows
        • Web
          • Web SDK Integration
          • Web SDK Releases
        • Unity
        • Unreal Engine
        • Godot Engine
      • Automatic payment tracking
        • App Store
        • Google Play
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anticheat methods
        • Track sessions
      • Push notifications
        • Android
        • iOS
        • Windows (UWP)
        • Unity
          • Android
          • iOS
          • Windows (UWP/WSA)
        • Unreal Engine
      • A/B testing
        • Description of A/B testing on the SDK side
        • Working with A/B tests in the devtodev interface
        • A/B testing examples
    • Integration of SDK 1.0+ (deprecated)
      • SDK Integration
        • iOS
        • Android
        • Windows 8.1 and 10
        • Web
        • Unity
        • Mac OS
        • Adobe Air
        • UE4
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anti-cheat Methods
      • Push Notifications
        • IOS
        • Android
        • Windows 8.1 and Windows 10
        • Unity
        • Abode Air
        • UE4
    • Test Devices
    • Server API
      • Data API 2.0
      • Subscription API
      • Push API
        • IOS
        • Android
        • Windows UWP
        • Windows
      • Raw Export
      • Labels API
      • Data API
    • Import historical data via API
    • Data Export
      • Data Export to Cloud Storage (BigQuery / Amazon S3)
  • 3rd Party Sources
    • Attribution Trackers
      • AppsFlyer
      • Adjust
      • Branch.io
      • Kochava
      • Tenjin
      • Tune (MAT)
      • Singular
      • Custom postback API
      • Facebook Ads referral decryption
    • App Marketplace Data
      • App Store Connect Stats
      • App Store Subscriptions
      • Google Play Console Stats
      • Google Play Subscriptions
      • AppGallery Connect Stats
    • Ad revenue
      • AdColony
      • AdMob
      • Facebook
      • MoPub
      • Unity Ads
      • Vungle
      • Ad revenue API
    • Cohort export
  • Reports and Functionality
    • Space-related Reports and Functionality
      • Overview
      • Custom dashboards & Reports
      • SQL
        • SQL tips
        • SQL Query examples
      • Audience overlap
    • Project-related Reports and Functionality
      • Overview
        • Real-Time Dashboard
        • Acquisition reports
        • Engagement reports
        • Monetization reports
        • In-game analysis reports
        • Cohort analysis
      • Reports
      • Push Notifications
        • Android Notifications
        • IOS Notifications
        • Windows Notifications
        • Button Templates
      • Predictions
      • Users & Segments
      • Filters
      • A/B Testing
      • Tuning
      • Settings
  • Metrics and Glossary
    • Ad networks metrics
    • Market Metrics
    • Prediction Metrics
    • SDK Metrics
    • Subscription metrics
  • Space Management
  • User Profile Management
  • Limits
  • Scenarios and Best Practices
    • Analytics use cases
    • Match-3
    • MMORPG Games
    • Hyper-Casual games
    • Social Casino
    • RPG games
    • Farming games
    • Non-gaming app
    • Acquisition Example
  • FAQ
    • Identification
    • Raw Data
    • All about data discrepancies
  • Slack
Powered by GitBook
On this page
  • Google implementation
  • Step 1. Declare repositories
  • Step 2. Add Gradle Build Dependencies
  • Huawei implementation
  • Step 1. Declare repositories
  • Step 2. Add Gradle Build Dependencies
  • Step 3. AppGallery
  • SDK Initialization
  • SDK obfuscation rules
  • Apps targeted at children

Was this helpful?

Export as PDF
  1. Integration
  2. Integration of SDK 2.0+
  3. SDK Integration

Android

PreviousSDK IntegrationNextiOS

Last updated 1 month ago

Was this helpful?

The SDK is available as an AAR (recommended) and JAR library. The library is available in the MavenCentral and .

Google implementation

Attention!

From the SDK version com.devtodev:android-analytics:'2.2.3' and above you need to add com.devtodev:android-google:'1.0.1'.

This framework encapsulates work with Google ads ID. When developing and publishing apps for kids , you don’t need com.devtodev:android-google. You can find more information about working with at the end of this guide.

Step 1. Declare repositories

In the Project build.gradle file, declare the mavenCentral repository:

repositories {
   //.. other repositories 
   mavenCentral()
}

Step 2. Add Gradle Build Dependencies

If you use Gradle for building apps specify the following dependencies in the application build.gradle file.

dependencies {
    // Requirement
    implementation ("com.google.code.gson:gson:*.*.*")
    implementation ("com.google.android.gms:play-services-ads-identifier:*.*.*")
    // Starting from version 2.2.3 and above, it is required
    implementation ("com.devtodev:android-google:*.*.*")

    // if you use AAR (recommended) or JAR downloaded from GitHub, please add:
    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar"))))

    // or just add the dependency, get the latest version from
    // https://mvnrepository.com/artifact/com.devtodev/android-analytics
    implementation ("com.devtodev:android-analytics:*.*.*")

    // Optional (recommended)
    implementation ("com.android.installreferrer:installreferrer:*.*.*")
}
dependencies {
    // Requirement
    implementation 'com.google.code.gson:gson:*.*.*'
    implementation 'com.google.android.gms:play-services-ads-identifier:*.*.*'
    // Starting from version 2.2.3 and above, it is required
    implementation 'com.devtodev:android-google:*.*.*'
    
    // if you use AAR (recommended) or JAR downloaded from GitHub, please add:
    implementation fileTree(dir: "libs", include: ["*.aar"]) 
    
    // or just add the dependency, get the latest version from
    // https://mvnrepository.com/artifact/com.devtodev/android-analytics
    implementation 'com.devtodev:android-analytics:*.*.*'
    
    // Optional (recommended)
    implementation 'com.android.installreferrer:installreferrer:*.*.*'
}

Peculiarities of working with dependencies

Working with Advertising ID with Android API level less than 26

android {
    defaultConfig {
        // Required when setting minSdkVersion to 20 or lower
        multiDexEnabled = true
    }
    compileOptions {
        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled = true
        // Sets Java compatibility to Java 8
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
dependencies {
    // For AGP 7.4+
    coreLibraryDesugaring ("com.android.tools:desugar_jdk_libs:2.0.3")
    // For AGP 7.3
    // coreLibraryDesugaring ("com.android.tools:desugar_jdk_libs:1.2.3")
    // For AGP 4.0 to 7.2
    // coreLibraryDesugaring ("com.android.tools:desugar_jdk_libs:1.1.9")
}
android {
    defaultConfig {
        // Required when setting minSdkVersion to 20 or lower
        multiDexEnabled true
    }
    compileOptions {
        // Flag to enable support for the new language APIs
        coreLibraryDesugaringEnabled true
        // Sets Java compatibility to Java 8
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
dependencies {
    // For AGP 7.4+
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3'
    // For AGP 7.3
    // coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.3'
    // For AGP 4.0 to 7.2
    // coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.9'
}

We also recommend AGP 8.0+ as it makes it easier to configure com.android.tools:desugar_jdk_libs

Huawei implementation

Step 1. Declare repositories

If you use Gradle for compiling apps, declare the following dependencies in the build.gradle file in the dependency block:

repositories {
   //.. other repositories 
   mavenCentral()
   maven { url 'https://developer.huawei.com/repo/' }
}

allprojects {
    repositories {
        //.. other repositories
        mavenCentral()
        // Configure the Maven repository address for the HMS Core SDK.
        maven {url 'https://developer.huawei.com/repo/'}
    }
}

Step 2. Add Gradle Build Dependencies

In the Project build.gradle file declare the agconnect plugin

dependencies {
    classpath 'com.huawei.agconnect:agcp:*.*.*'
}

In the application build.gradle file declare the following dependencies:

dependencies {
    // Requirement
    implementation ("com.google.code.gson:gson:*.*.*")
    implementation ("com.huawei.agconnect:agconnect-core:*.*.*")
    implementation ("com.huawei.hms:opendevice:*.*.*")
    // Starting from version 2.2.3 and above, it is required
    implementation ("com.devtodev.android-huawei:*.*.*")
    implementation ("com.huawei.hms:ads-identifier:*.*.*")
    
    // if you use AAR (recommended) or JAR downloaded from GitHub, please add:
    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar"))))
    
    // or just add the dependency, get the latest version from
    // https://mvnrepository.com/artifact/com.devtodev/android-analytics
    implementation ("com.devtodev:android-analytics:*.*.*")
}
dependencies {
    // Requirement
    implementation 'com.google.code.gson:gson:*.*.*'
    implementation 'com.huawei.agconnect:agconnect-core:*.*.*'
    implementation 'com.huawei.hms:ads-identifier:*.*.*'
    implementation 'com.huawei.hms:opendevice:*.*.*'
    // Starting from version 2.2.3 and above, it is required
    implementation 'com.devtodev.android-huawei:*.*.*'
    
    // if you use AAR (recommended) or JAR downloaded from GitHub, please add:
    implementation fileTree(dir: "libs", include: ["*.aar"]) 
    
    // or just add the dependency, get the latest version from
    // https://mvnrepository.com/artifact/com.devtodev/android-analytics
    implementation 'com.devtodev:android-analytics:*.*.*'
}

And add a plugin:

plugins {
    //.. other plugins
    id 'com.huawei.agconnect'
}

Step 3. AppGallery

  1. Create a project and an app in AppGallery. Open AppGalleryConnect → Project Settings.

SDK Initialization

Use the following way to initialize the library in the first Activity onCreate() method:

class MainActivity : Activity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
      
        val analyticsConfiguration = DTDAnalyticsConfiguration()
        analyticsConfiguration.logLevel = DTDLogLevel.Error
        DTDAnalytics.initialize("App ID", analyticsConfiguration, context = this)
    }
}
public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        DTDAnalyticsConfiguration configuration = new DTDAnalyticsConfiguration();
        configuration.setLogLevel(DTDLogLevel.Error);
        DTDAnalytics.INSTANCE.initialize("App ID", configuration, context);
    }
}
  • You can find the App ID in the settings of the respective app in devtodev (Settings → SDK → Integration → Credentials).

  • config - is a DTDAnalyticsConfiguration object instance that is used for specifying additional properties during initialization.

DTDAnalyticsConfiguration

Parameter

Type

Description

currentLevel

Integer

The player level at the moment of devtodev SDK initialization. It’s optional but we recommend using it for improving data accuracy.

userId

String

A custom user ID assigned by the developer. In the case of default calculation by device IDs, the identifier can be used for searching users in devtodev. In case the project uses calculation by user IDs, the parameter is mandatory because it becomes the principal calculation ID in devtodev.

trackingAvailability

DTDTrackingStatus (enum)

The property allows or disallows devtodev tracking of the user. By default, it is set to DTDTrackingStatus.enable. SDK stores the previously assigned value. Pass DTDTrackingStatus.disable if the user opted out of tracking in line with GDPR.

logLevel

DTDLogLevel (enum)

The level of logging the SDK activity. The DTDLogLevel.no value is used by default. For troubleshooting during integration it is recommended to set it to DTDLogLevel.debug, and either switch it off DTDLogLevel.no. Use DTDLogLevel.no in the release version.

Example:

val config = DTDAnalyticsConfiguration()
config.currentLevel = 1
config.userId = "CustomUserID"
config.trackingAvailability = DTDTrackingStatus.Enable
config.logLevel = DTDLogLevel.No
DTDAnalytics.initialize("App ID", config, context = this)
DTDAnalyticsConfiguration config = new DTDAnalyticsConfiguration();
config.setCurrentLevel(1);
config.setUserId("CustomUserID");
config.setTrackingAvailability(DTDTrackingStatus.Enable);
config.setLogLevel(DTDLogLevel.No);
DTDAnalytics.INSTANCE.initialize("App ID", config, context);

SDK obfuscation rules

Add the following strings to the proguard-rules.pro file of your app

-keep class com.devtodev.** { *; }
-dontwarn com.devtodev.**
// For Google Mobile Services 
-keep class com.google.android.gms.** { *; }
// For Huawei Mobile Services 
-keep class com.huawei.hms.**{*;}

Apps targeted at children

When developing and publishing apps targeted at children under 13 years old, you need to ensure special conditions for data processing. Any mobile app aimed at children or intended for users in a region with strict regulations on child online protection, must comply with current laws.

Please study the following requirements:

If your app has to comply with the legal requirements (COPPA), use the following recommendations:

  1. Implement the coppaControlEnable method. The method disables collection of ad IDs and vendor IDs.

  2. If your app is using Google services, remove the following dependencies from gradle:

    'com.google.android.gms:play-services-ads-identifier'  
    'com.devtodev:android-google'
  3. If your app is using Huawei services, remove the following dependencies from gradle:

    'com.huawei.hms:ads-identifier' 
    'com.huawei.hms:opendevice' 
    'com.devtodev.android-huawei'

Call the coppaControlEnable method before SDK initialization. If the method was not called, the SDK will work as before.

DTDAnalytics.coppaControlEnable()
DTDAnalytics.initialize("App ID", config, context = this)
DTDAnalytics.INSTANCE.coppaControlEnable();
DTDAnalytics.INSTANCE.initialize("App ID", config, context);

If you plan to use com.google.android.gms:play-services-ads-identifier:18.2.0 and above, you need to add com.android.tools:desugar_jdk_libs to maintain backward compatibility with devices with API level less than 26, see

For more information see .

The com.devtodev.android-huawei framework works with and IDs. In case the is undefined, we use the . For both IDs to work correctly, take the following steps:

Sign your app using a certificate (see ).

Enter SHA-256 certificate in the App information section. Read more about certificate creation .

After taking all the steps described above, open the ‘App information’ section and download agconnect-services.json. You need to place this file in the app folder ().

If during testing the app you see that is unavailable and throws , you need to first of all check that the tested build is signed with a certificate.

USA:

EU:

GitHub repository
COPPA
COPPA
huawei official documents
OAID
ODID
OAID
ODID
here
here
read more
OAID
OAID
errors
Children’s Online Privacy Protection Act (COPPA)
General Data Protection Regulation (GDPR) Article 8
Use Java 8 language features and APIs | Android Studio | Android Developers