Android (x)
Things to keep handy before starting your integration with Apxor
Please have the following handy before beginning the integration:
Application identifier generated on the Apxor dashboard for your app (Read more on how to fetch the application identifier from Apxor dashboard)
App Bundle Id : Every android app has a unique application ID that looks like
com.example.myapp
. This id uniquely identifies the app on the device and also on the google play store.
Note
Please add .apxor as suffix to the bundle id when adding on Apxor Dashboard
eg. com.example.myapp.apxor
(Know more about bundle ids here)
The list of events to setup triggers and track goals, user properties that allows to personalize messages and to target better. (Read more on how you can setup here)
Note
If you are already using a separate analytics class where you are sending events to different platforms from a single place it is much faster to use our tracking guide to complete event logging to setup triggers and track goals.
In case you are logging events to third parties after each interaction, please use our Third party API guide to migrate all the events that you are sending to one of the supported third parties as listed in the guide.
Firebase Cloud Messaging (FCM) Server Key : For tracking uninstalls, Apxor sends silent push notifications to measure your campaign outcomes. (Read more on how to fetch firebase credentials that are used to setup uninstall tracking during integration here)
Understanding dependencies to add to your project
Step 1: Add Apxor Repository
Add Maven URL in project level build.gradle
file to load the plugins.json
file you will create in Step 3.
Path: <project>/build.gradle
:
Step 2: Add ApxorSDK
Add plugin dependencies to your application build.gradle
file
Path: <project>/<app-module>/build.gradle
:
Check the latest release notes here.
Step 3: Create Apxor Configuration File
Create an assets folder
in android app module
and create the plugins.json
that contains the below code.
This is used to initialise the dependencies that are used while adding Apxor SDK in the third step.
Path: src/main/assets/plugins.json
:
Step 4: Add exoplayer in your app (optional)
Exoplayer enables to configure Picture In Picture videos from Apxor dashboard and typically increases the app size by ~1Mb, if you are already using exoplayer in your app this step is not needed else add the following dependency in the application build.gradle
file
Path: <project>/<app-module>/build.gradle
:
Step 5: Disable Dexing Artifact Transformation
Note
In the Android Gradle Plugin 3.5.0, we desugar & dex using Gradle artifact tranforms, which allow more parallelism and caching. This mechanism relies on libraries having the correct Maven information, because we use dependencies specified in POM files to set up the desugaring classpath. In cases we are unable to see all dependencies when desugaring a class it is required to disable parallel transformation to faciliate the process by adding the property as mentioned below.
Add the following properties gradle.properties
file
Path: <project>/<app-module>/gradle.properties
:
Step 6: Add the following in proguard-rules.pro
Note
If you use proguard to obfuscate the classes, you have to add the following to ignore obfuscation for Apxor SDK classes
Configure the below rules in your proguard-rules.pro
file
Path: <project>/<app-module>/proguard-rules.pro
:
Step 7: Enable uninstall tracking for your users (optional)
Note
Apxor does not support firebase-messaging >= 22.0
while using the push plugin that helps track uninstalls. If your applpication is using firebase-messaging >=22.0
please remove android-sdk-push
during integration
Apxor uses your firebase server key to send silent push notifications to track uninstalls in order to measure outcomes of your campaign. To enable this please do the following :
Path: <project>/<app-module>/build.gradle
:
Step 8: Install Referrer Dependency (optional)
Install referrer dependency is optional , if added we can provide install attribution.
Path: <project>/<app-module>/build.gradle
:
Step 9: Initialize SDK
To Auto initialize SDK (Recommended), add following meta-data
tag inside your application
tag in your AndroidManifest.xml
file
Path: <project>/<app-module>/src/AndroidManifest.xml
:
Here is how you can get the Apxor Application Identifier as mentioned in the Integration Essentials section
Step 10: Yay, Verify your SDK integration
We have to verify for two things as follows :
SDK Initialisation
On running your android project lookout for the following log in logcat :
Plugin Initialization
By default, only error logs are enabled. To see debug logs for plugin initialization and to confirm tracking event triggers, user properties. Please run the below command in terminal
Step 11: Log data to set up triggers and measure goals
Now as we are done with basic integration, we can go ahead to setup event triggers, capture data for targeting and to personalize messaging. Please follow the guide here to log user properties, events and event properties.
Last updated