Getting Started
With the NAM SDK, you can monetize your Android app through ads from various ad providers. This guide explains how to integrate ads into your Android app using the NAM SDK.
Prerequisites
- Install or update to the latest version of Android Studio.
- minSdkVersion 21 or higher
Adding NAM SDK to Your App
1. Include the MavenCentral repository in your Gradle settings file.
- Kotlin DSL
- Groovy
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
// . . .
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
// . . .
}
}
2. Add the following dependencies to your app-level build.gradle file.
It is recommended to use the NAM Android BoM for managing library versions provided by the NAM SDK.
- Kotlin DSL
- Groovy
dependencies {
// Import the BoM for the NAM platform
implementation(platform("com.naver.gfpsdk:nam-bom:8.4.1"))
// When using the BoM, you don't specify versions in NAM library dependencies
// Add the NAM Core dependency (required)
implementation("com.naver.gfpsdk:nam-core")
// Add the S2S mediation library dependency (required)
implementation("com.naver.gfpsdk.mediation:nam-nda")
// TODO: Add the dependencies for any other mediation libraries you want to use
// For example, add the mediation library dependencies for Google Ad Manager, Meta Audience Network
implementation("com.naver.gfpsdk.mediation:nam-dfp")
implementation("com.naver.gfpsdk.mediation:nam-fan")
...
}
dependencies {
// Import the BoM for the NAM platform
implementation platform('com.naver.gfpsdk:nam-bom:8.4.1')
// When using the BoM, you don't specify versions in NAM library dependencies
// Add the NAM Core dependency (required)
implementation 'com.naver.gfpsdk:nam-core'
// Add the S2S mediation library dependency (required)
implementation 'com.naver.gfpsdk.mediation:nam-nda'
// TODO: Add the dependencies for any other mediation libraries you want to use
// For example, add the mediation library dependencies for Google Ad Manager, Meta Audience Network
implementation 'com.naver.gfpsdk.mediation:nam-dfp'
implementation 'com.naver.gfpsdk.mediation:nam-fan'
...
}
3. Add the Publisher Code issued via the NAVER Ad Manager platform or your contact person to AndroidManifest.xml as follows.
<manifest>
<application>
<meta-data
android:name="com.naver.gfpsdk.PUBLISHER_CD"
android:value="YOUR_PUBLISHER_CODE" />
</application>
</manifest>
The Publisher Code is a required field. If omitted, the app may crash during startup. Ensure this value is included.
4. Add the Google Play Services SDK to collect AD ID.
The NAM SDK collects Google Advertising ID (AD ID) to support advanced ad targeting. To enable your application to retrieve AD ID, refer to the following:
- Kotlin DSL
- Groovy
dependencies {
implementation("com.google.android.gms:play-services-ads-identifier:17.0.1")
...
}
dependencies {
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
...
}
Additional Considerations
The following are additional considerations when integrating the NAM SDK.
SDK Initialization
The NAM SDK requires initialization for ad requests and monetization. However, initialization is automatically handled internally when the application starts, so no additional initialization code is needed.
If you need to control the initialization timing in specific scenarios, manual initialization is also available. For more details, refer to the Manual Initialization Guide.
App Set ID
App Set ID helps uniquely track users per device and developer account on the app store. To enable your application to retrieve App Set ID, refer to the following:
- Kotlin DSL
- Groovy
dependencies {
implementation("com.google.android.gms:play-services-appset:16.0.2")
...
}
dependencies {
implementation 'com.google.android.gms:play-services-appset:16.0.2'
...
}
Chrome Custom Tabs
To use Chrome Custom Tabs instead of an external browser when clicking ads, add the Chrome Custom Tabs library to your application.
- Kotlin DSL
- Groovy
dependencies {
implementation("androidx.browser:browser:1.4.0")
...
}
dependencies {
implementation 'androidx.browser:browser:1.4.0'
...
}
When Using WebView
If your app uses NAM Web SDK to display ads in a WebView, each WebView object must be registered with the SDK. This ensures accurate ad targeting and improves ad revenue by enabling communication with websites using the NAM Web SDK. Ensure you use version 8.2.4 or higher and apply the WebView Registration Guide.
Network Security Configuration
Some mediation networks provide ad creatives via cleartext (non-HTTPS) traffic. Since Android 9.0 (API 28) blocks HTTP traffic by default, this may impact user experience and ad revenue. To maximize revenue, it is recommended to allow HTTP traffic. Affected mediation networks include:
Choosing an Ad Format
Once the above steps are complete, you are ready to integrate ads using the NAM SDK. Now, select the ad format you want to use in your app and add the corresponding ads.
The NAM SDK supports various ad formats. Below are the main ad formats:
You can find the sample code for the NAM SDK in the NAM Android SDK GitHub repository.