Mobile SDK end-of-life has been announced and scheduled for the end of March 2024, in favor of updated and more streamlined app personalization using server-side APIs.
Dynamic Yield offers software development kits (SDKs) for native mobile platforms, enabling you to personalize your native app experience for your users. This article contains information about how to install and update the SDK for Android platforms.
Note: This SDK requires Android 4.1 or higher.
Installing the Library
Step 1: Create a New Site and Download the SDK
To set up a new Android application, perform the following in the Dynamic Yield administration console:
-
Create a new site and select Mobile App and operating system › Android.
- Click Create, you will be redirected to the General Settings page. Under the Implementation Status › Download the SDK.
Step 2: SDK integration
- In your project’s build.gradle file, add DY’s package repository:
allprojects { 2 repositories { 3 ......other repos 4 //add the following line 5 maven { url "https://maven.pkg.github.com/DynamicYield/android-sdk" } 6 } 7}
- In your app’s build.gradle file, add the following dependency:
dependencies { 2 ......other dependencies 3 //add the following line 4 implementation 'com.dynamicyield:DYAPISDK:+' 5}
- Use ‘+’ for the latest version, or specify the required SDK version ( Example: ‘3.7.8’ )
In Android Studio, create a new module that will hold the downloaded SDK (an ARR file):
- Click New › Module.
- Select Import JAR / AAR Package as the module type.
- Specify the path to the SDK (the AAR file).
- Click Finish to save your new module.
Connect your app to the module you just created:
- Right-click on your app and click Open Module Settings.
- Click Dependencies and add a new dependency of type Module Dependency.
- Choose the new module that you created earlier in this procedure.
Step 3: Add Your Secret App Key
To start using the Dynamic Yield API in your app, set up your application secret key
- Copy your application secret key from your new site title in Site Settings.
- In your Application class, initialize the object using the following example code:
@Override public void onCreate() { super.onCreate();
//if you are using our EU data center uncomment the following lines:
//DYCustomSettings settings = new DYCustomSettings();
//settings.useEuropeanServer(true);
//DYApi.setCustomSettings(settings); DYApi.setContextAndSecret(getApplicationContext(),YOUR_SECRET_KEY); // Other init code }- Replace “YOUR_SECRET_KEY” with the key obtained above
- If you are using our EU data center, uncomment the line specified in the code above.
Using Proguard
DynamicYield SDK uses open-source software that does not support Proguard, if your app is using Proguard, please add this to your build.gradle file:
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
The content of proguard-rules.txt should be:
-keep class com.dynamicyield.** { *; }
-keeppackagenames com.dynamicyield.**
Updating The Library
The Dynamic Yield SDK is updated periodically and is always backward compatible. To use new features, you need to update the Dynamic Yield SDK installed in your app.
Manual Installation
Repeat steps 1 – 3 in the SDK integration manual installation with the new SDK version you download from the site. When prompted, choose ‘override’ so the new jar version replaces the previous version.