Guide
Install
Add the SDK from Maven Central and NGA's public repositories, at 0.1.0. Choose your engine; the choice holds on every page.
What you add #
| Engine | From | Signals only | Signals and ads |
|---|---|---|---|
| Unity | Unity's Package Manager, from a Git URL | network.nga.sdk |
network.nga.sdk and network.nga.sdk-render |
| Android | Maven Central, group network.nga, through the BOM nga-bom |
nga-sdk |
nga-sdk and nga-sdk-render |
| iOS | Swift Package Manager, https://github.com/nga-io/nga-sdk-ios |
product NGASDK |
product NGASDKRender |
- Use 0.1.0 for every coordinate on this page. It reports
0.1.0, fromgetSdkVersion()and in what it sends to NGA. 0.1.0 is the build of its last release candidate, 0.1.0-rc.6, published again under the plain version. The candidates reported0.1.0too: only their coordinates and tags (the BOM's version, the Swift package's version, the Unity tag) carried-rc.N. - Keep both libraries at the same version, from the same release. Otherwise the render library is not used, and every ad call returns
RENDER_NOT_AVAILABLE / render.version_mismatch; everything else works. Two builds of one version, two candidates or the release and a candidate other than its own build (0.1.0 is 0.1.0-rc.6's), both report 0.1.0, so from 0.1.0-rc.3 on each library also carries the id of the build it came from, and a core library at 0.1.0-rc.3 or later refuses a render library from another build the same way; in Unity, its build check fails such a pair first. An older core library catches neither. Move both packages to a new tag in one edit. - No KDoc in the IDE: the sources jar on Maven Central carries none; the API is on the Reference pages.
Add the SDK #
Unity (C#)
1. An External Dependency Manager. Skip if your project already has one (the MAX and Google Mobile Ads plugins include one; LevelPlay offers to install its Mobile Dependency Resolver when you open the project), or if the game is iOS-only. Otherwise add Unity's com.unity.external-dependency-manager 2.1.1 or later: Window > Package Manager > + > Add package by name. Google's com.google.external-dependency-manager (EDM4U) also works but is deprecated. The NGA build check accepts any of these, as a package or as files under Assets/. Why: Unity's build does not read the SDK's Android dependencies from its packages.
2. The two packages, at one tag. Requires Git on your machine. In Window > Package Manager, choose + > Add package from git URL… and add the core library first, then the render library:
https://github.com/nga-io/nga-sdk-unity.git?path=com.nga.sdk#v0.1.0
https://github.com/nga-io/nga-sdk-unity.git?path=com.nga.sdk-render#v0.1.0
Or put both lines in Packages/manifest.json yourself, merged into your existing dependencies:
{
"dependencies": {
"network.nga.sdk": "https://github.com/nga-io/nga-sdk-unity.git?path=com.nga.sdk#v0.1.0",
"network.nga.sdk-render": "https://github.com/nga-io/nga-sdk-unity.git?path=com.nga.sdk-render#v0.1.0"
}
}
The folder in the URL (com.nga.sdk) is not the package name (network.nga.sdk); that is expected. Always add the core library: network.nga.sdk-render needs network.nga.sdk in your manifest at the same tag.
3. Player settings.
- Android > Other Settings: Minimum API Level 23 or later.
- Android > Publishing Settings > Minify: on Unity 2022.3, turn on Release (
PlayerSettings.Android.minifyRelease), and Debug (PlayerSettings.Android.minifyDebug) if you make development builds, and keep them on. Unity's default is off for both. With it off, a 2022.3 release build fails at the dexing step on the SDK's Kotlin libraries (Troubleshooting), and the NGA build check stops a release or development build before Gradle runs, unless the project puts R8 8 or later on its build classpath (step 4). Unity 6 builds either way. - Android > Publishing Settings: turn on Custom Main Gradle Template and Custom Gradle Properties Template, so the External Dependency Manager can write the SDK's Android dependencies into them (leave them as they are if your mediation already turned them on). Then run Assets > External Dependency Manager > Android Resolver > Resolve.
- iOS > Other Settings: Target minimum iOS Version 15.0 or later. Nothing else for iOS: the build embeds and signs the SDK's two frameworks, each with its own privacy manifest.
- With
network.nga.sdk-render, on every platform: Resolution and Presentation > Render Over Native UI off (PlayerSettings.preserveFramebufferAlpha). The native banner is drawn above your game's surface; with this setting on, the game would cover it.
4. Only for Unity 2022.3 Android builds with a recent mediation SDK (MAX 13, LevelPlay 9.6 or later). Unity 2022.3 cannot dex these SDKs with its own tools. Turn on Custom Gradle Settings Template and add R8 to the build classpath, after the pluginManagement { … } block. Any R8 from 8.5.35 works; the snippet uses 8.7.18:
buildscript {
repositories { google(); mavenCentral() }
dependencies { classpath 'com.android.tools:r8:8.7.18' }
}
Android (Kotlin)
1. Maven Central. Most projects have it. If yours does not, add it to the repositories in settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}
2. The SDK, through its BOM. The BOM pins both libraries at one version, so you name the version once:
dependencies {
implementation(platform("network.nga:nga-bom:0.1.0"))
implementation("network.nga:nga-sdk")
implementation("network.nga:nga-sdk-render") // only if your game shows NGA ads
}
In a Groovy build.gradle, the same lines are implementation platform('network.nga:nga-bom:0.1.0'), implementation 'network.nga:nga-sdk' and implementation 'network.nga:nga-sdk-render'.
The libraries bring what they need at runtime: the Kotlin standard library (1.9 or later), Google's Play Install Referrer library and App Set. Add none of them yourself. nga-sdk-render requires nga-sdk at exactly its own version, so Gradle refuses a build that pulls a different core library beside it.
3. Check the app.
minSdkis 23 or more.- Your merged manifest has
INTERNET(required; without it the SDK sends nothing) andACCESS_NETWORK_STATE(recommended). The SDK does not add them. Most ad or analytics SDKs do; if yours do not, declare them yourself. - Nothing else: the libraries carry their own R8 keep rules and need no other manifest entry. The SDK reads the advertising id only if your app ships Google's
play-services-ads-identifier(most ad SDKs bring it); you need not add it for NGA.
Java apps use the same libraries; see Conventions.
iOS (Swift)
1. Add the package. In Xcode: File > Add Package Dependencies…, enter https://github.com/nga-io/nga-sdk-ios, and set the Dependency Rule to Exact Version, 0.1.0. Name it exactly, as the BOM and the Unity tag do: a range can move you to a newer version, and before 1.0 a minor version can change the API. The repository's tag is v0.1.0; Xcode and Package.swift name the version without the v.
2. Add one product to your app target:
NGASDKRenderif your game shows NGA ads. It bringsNGASDKwith it.NGASDKif it does not.
Xcode embeds and signs both frameworks. Each carries its own privacy manifest; see What each library declares.
If your game code is in a local Swift package, add the dependency to its Package.swift:
// swift-tools-version:5.9
import PackageDescription
let package = Package(
name: "Game",
platforms: [.iOS(.v15)],
dependencies: [
.package(url: "https://github.com/nga-io/nga-sdk-ios", exact: "0.1.0"),
],
targets: [
.target(name: "Game", dependencies: [
.product(name: "NGASDKRender", package: "nga-sdk-ios"), // or "NGASDK" for signals only
]),
]
)
3. Set the deployment target to iOS 15.0 or later, and build with Xcode 26 or later.
In your code, import NGASDK. You never import NGASDKRender or name anything from it: the SDK finds it at initialize.
Unity build checks #
The Unity package fails an Android or iOS build when a setting would break the SDK on the device. The error starts with NGA SDK: this build cannot run the NGA SDK. and has one line per problem:
| The build says | Fix |
|---|---|
| Minimum API Level is n; the NGA SDK needs API 23 or later | Player > Android > Other Settings > Minimum API Level: Android 6.0 (API level 23) or later |
| Target minimum iOS Version is n; the NGA SDK needs iOS 15.0 or later | Player > iOS > Other Settings > Target minimum iOS Version: 15.0 or later |
The External Dependency Manager for Unity (com.google.external-dependency-manager) is not installed (Android builds) |
add an External Dependency Manager (step 1 above), then Assets > External Dependency Manager > Android Resolver > Resolve; Unity's com.unity.external-dependency-manager satisfies the check too. Without it the build would succeed, but initialize would fail on the device because kotlin-stdlib is missing |
network.nga.sdk is at one version and network.nga.sdk-render at another |
set both to the same tag in Packages/manifest.json |
network.nga.sdk carries native build a and network.nga.sdk-render build b: both are at one version, from two builds of it (two candidates, or the release and a candidate before 0.1.0-rc.6) |
install both packages from one release: the same tag in both Git URLs |
| Unity 2022.3 builds this Android release build (or development build) without minify | turn on Player > Android > Publishing Settings > Minify > Release (or Debug), as in step 3; or build with Unity 6 |
| Render Over Native UI is on | Player > Resolution and Presentation > Render Over Native UI: off |
Updating #
A new version changes one value: the tag in your two Unity Git URLs, the BOM's version on Android, or the exact version of the Swift package. Change both Unity lines in one edit, and let the Package Manager resolve both before you build: a core library older than 0.1.0-rc.3 does not notice a render library from a newer build of its version. Read the changelog first.
Going back to an older version is safe from 0.1.0-rc.3 on: where a newer SDK saved its files on the device in a shape the older one does not know, the older one sets them aside and starts as a new install there.
Next #
Initialize the SDK.