Skip to content

About

Unity plugin for Adivery ads

Resources

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

71 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adivery Unity Plugin

A Unity plugin that wraps the Adivery Android SDK (mediated ad network: rewarded, interstitial, OfferWall, banner, and native ads) for use from C# in a Unity project. Android only — every call is a no-op on other platforms.

Repo layout:

Assets/Adivery/            → the plugin itself (this is what gets exported/installed)
Assets/Plugins/Android/    → Gradle template used when building the sample (the SDK itself is a Maven dependency, not a bundled AAR)
source/plugin/             → a full Unity project used to build/export the package and host the sample scene

Requirements

  • Unity 6000.0.75f1 (see source/plugin/ProjectSettings/ProjectVersion.txt) with Android Build Support installed
  • Android SDK/NDK (Unity's bundled Android module works; ANDROID_HOME/ANDROID_SDK_ROOT must point at one) — needed to build the sample APK; not needed to export the plugin package itself
  • JDK, matching whatever Unity's own internal Android/Gradle build needs — only relevant when building the sample APK, not for exporting the plugin package

Installing the plugin in your own project

The distributable is a .unitypackage containing just Assets/Adivery (no bundled AAR; the native SDK is pulled in as a Maven dependency, per the Unity integration docs). Build it with the release-plugin Claude Code skill in this repo (.claude/skills/release-plugin/), or manually:

UNITY_EXE=/path/to/Unity "$UNITY_EXE" -batchmode -nographics \
  -projectPath source/plugin \
  -exportPackage Assets/Adivery Adivery.unitypackage \
  -quit

This produces Adivery.unitypackage at the repo root. Import it into your Unity project via Assets > Import Package > Custom Package.

Basic usage once imported:

using AdiveryUnity;

Adivery.Configure("YOUR_APP_ID");
Adivery.SetUserId("YOUR_USER_ID"); 

var listener = new AdiveryListener();
listener.OnInterstitialAdLoaded += (s, placementId) => Adivery.Show(placementId);
Adivery.AddListener(listener);
Adivery.PrepareInterstitialAd("YOUR_PLACEMENT_ID");

See Assets/Adivery/Adivery.cs, AdiveryListener.cs, BannerAd.cs, and NativeAd.cs for the full API (interstitial/rewarded/OfferWall via Adivery + AdiveryListener events, banners via BannerAd, native ads via NativeAd). OfferWall needs com.adivery:sdk 4.10.0-alpha.1 or later; on older SDKs Adivery.PrepareOfferWallAd throws, since the native method doesn't exist. Unlike interstitial/rewarded, the SDK doesn't prefetch another OfferWall after one closes, so call Adivery.PrepareOfferWallAd again before each show (the sample prepares on button tap and shows from OnOfferWallAdLoaded).

Running the sample app

source/plugin is a self-contained Unity project. Its MainScene (Assets/Scenes/MainScene.unity, driven by Assets/Scripts/AdsController.cs) exercises every ad type against a demo app ID/placements.

Open source/plugin directly in Unity Hub/Editor, then File > Build Settings > Android > Build And Run (with a device connected) or just press Play in the Editor to test in-Editor UI wiring (ads themselves only work on device, since the SDK is Android-only).

To build headlessly instead, use the batchmode build script this repo already ships, Assets/Editor/BuildScripts/AdiverySampleBuild.cs (excluded from player builds and from the exported plugin package):

UNITY_EXE=/path/to/Unity ANDROID_HOME=/path/to/sdk \
  ADIVERY_SAMPLE_BUILD_OUTPUT=/path/to/AdiverySample.apk \
  "$UNITY_EXE" -batchmode -nographics \
    -projectPath source/plugin \
    -executeMethod AdiverySampleBuild.BuildAndroid \
    -quit

(ADIVERY_SAMPLE_BUILD_OUTPUT is optional — it defaults to build/AdiverySample.apk under source/plugin/.)

Or use the release-sample Claude Code skill in this repo (.claude/skills/release-sample/) to build it in one step.

Then install/run on a connected device:

adb install -r path/to/AdiverySample.apk
adb shell monkey -p com.adivery.unitysample -c android.intent.category.LAUNCHER 1

License

Apache License 2.0 — see LICENSE.

About

Unity plugin for Adivery ads

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages