SDK Setup
This guide walks you through integrating and initializing the Ogury SDK in your Android application. This step is required before displaying any ads.
Prerequisites
Before proceeding, make sure you have completed the steps outlined in the Getting Started section:
Registered your app and created ad units in the Ogury Publisher Platform.
Retrieved your asset key and ad unit IDs.
Updated your
app-ads.txt
file.
Compatibility Requirements
Before integrating the Ogury SDK, make sure your Android project is compatible with it:
Minimum API Level:
21
or higher.Target SDK Version:
33
or higher.Kotlin Version:
1.8.20
or higher.Permissions (in
AndroidManifest.xml
):
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Import the Ogury SDK
Add the Ogury Maven repository in your settings.gradle
:
// settings.gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
// Add Ogury's repository
maven {
url 'https://maven.ogury.co'
}
}
}
Then, add the Ogury SDK dependency in your module-level build.gradle
(usually app/build.gradle)
:
// build.gradle (Module: app)
dependencies {
implementation 'co.ogury:ogury-sdk:6.+'
// ... other dependencies
}
Initialize the Ogury SDK
Before using any Ogury features, initialize the SDK with your asset key using Ogury.start()
.
The asset key is in the format OGY-XXXXXXXXXXXX
, where X
represents an uppercase letter or digit. If you don’t have one, refer to the Getting Started guide.
If you're using a Consent Management Platform (CMP), it is recommended to wait until the user has provided consent before calling start()
.
Ogury.start(this, "OGY-XXXXXXXXXXXX", object : OguryOnStartListener {
override fun onStarted() {
// Initialization successful
}
override fun onFailed(error: OguryError) {
// Handle initialization failure
}
})
The start()
method takes the following parameters :
The application context (not an Activity).
Your unique Ogury asset key. If you don’t have one, refer to the Getting Started guide.
An optional but recommended
OguryOnStartListener
providing feedback on the initialization status:The
onStarted
callback is triggered on success.The
onFailed
callback is triggered on failure, returning anOguryError
object.
The OguryError
is returned containing an error code
and message
, helping you troubleshoot. The possible errors are defined in the OguryStartErrorCode
class for easy reference.
The OguryStartErrorCode
enum values
OguryStartErrorCode
enum valuesMODULE_MISSING
The SDK could not be started because a required SDK module is missing.
MODULE_FAILED_TO_START
The SDK could not be started because one of the required SDK modules failed to start.
What’s Next?
🎉Congratulations! The Ogury SDK is now initialized in your app. You are ready to start integrating ad formats.
Choose a format to continue integration:
Additional Resources
For information on privacy and regulatory compliance, see the Privacy Compliance section.
Last updated
Was this helpful?