Android
Pre-Requisites
To successfully use the SDK, make sure that the following steps are completed:
- All of your ApplicationIDs you plan to use during testing and production are registered by SOM (contact your publisher manager)
- Obtain your page domain mapping (please refer to your publisher manager to get your mapping)
AndroidX
The SDK is using AndroidX. Therefore, any application that utilises the SDK must add AndroidX support. If your project is not already enabled, add the following lines to your gradle.properties
:
android.useAndroidX=true
android.enableJetifier=true
MultiDex
The project must also enable multidex support. The following lines should be added under android
in your build.gradle
:
defaultConfig {
multiDexEnabled true
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
Install SevenOneAds
The SDK is hosted in a private Maven repository. To integrate the SDK into your application, you need to add the following lines to your project's build.gradle
file.
The following line should be added under repositories
in your build.gradle
:
maven { url "https://adtec-app-android-maven.s3.eu-central-1.amazonaws.com/" }
To add the dependency, add the following line should be added under dependencies
in your module's build.gradle
. Make sure to replace x.x.x
with the latest version.
implementation ('com.sevenonemedia:sevenoneads:x.x.x@aar') {
transitive = true //add this if you want to implicitly load SDKs dependencies too
}
Initialise SDK
In your main activity's onCreate() function, initialise the SDK by first creating a SevenOneAdsSettings and pass this object to the initialisation function.
override fun onCreate(savedInstanceState: Bundle?) {
...
// Initialise SevenOneAds
val settings = SevenOneAdsSettings(<application>, <pageTopDomain>, <pageSubDomain>, <contentUrl>, <metaData>)
SevenOneAds.initialise(settings) { isSuccesful ->
// Optionally handle isSuccesful
}
}
application
: The application object.pageTopDomain
: sets the top page domain. This would be the top topic of the current page, for example "football". The supported domains for your integration will be provided by SOM.pageSubDomain
: (Optional, default: null) sets the sub page domain. This would be the subtopic of the current page, for example "champions-league". The supported domains for your integration will be provided by SOM.contentUrl
: (Optional, default: null) sets the content url.metaData
: (Optional, default: null) Map<String, String> that allows to pass in custom key/value pairs. Only agreed upon key/values will be used. For more information please contact SOM.isSuccesful
: (Optional, default null) Optional initialisation listener that returns a boolean
Important Note: If the initialisation fails, please monitor your logs to find the cause. This is most likely due to an un-registered application ID. The SDK uses the
applicationId
to automatically identify which application is using the SDK. Each application is associated with a unique config file that is created and handled by SOM. Before a new application can use the SDK, the application ID must be registered by SOM. Using an unknown application ID will fail to initialise the SDK. If the initialisation fails (will be logged locally), or you are uncertain if your application ID is registered, please contact SOM.
Custom Meta Data
In some special cases it might be necessary to pass in custom meta data during initialisation. This should only be done if you have special requirements that have been discussed and approved by SOM in advance. All unknown data will be ignored by the SDK.
Enable SSL Proxying
In order to see network traffic, e.g. via Charles Proxy, you should add the according network security options to the manifest. Please make sure that the user certificates are only trusted for non-production builds.
There is a detailed guide how to do so here.
R8 / Proguard
The following information is valid for Android SDK versions >= 0.8.2. Earlier versions of the SDK do not support Proguard.
If you use this SDK as a dependency in an Android project which uses R8 as a default compiler you don’t have to do anything. The specific rules are already bundled into the AAR which can be interpreted by R8 automatically.
If you cannot use R8 as your compiler, please either extract the proguard rules from the AAR library and from all its dependencies or get in touch with SOM for further support.