Aller au contenu principal
Version: 6.x.x

Get Started

BlueStack Ads SDK provides functionalities for monetizing your mobile application: from premium sales with rich media, video and innovative formats, it facilitates inserting native mobile ads as well all standard display formats.

info

Looking for a working reference? Our public demo app on GitHub — azerion/azerion-inapp-demo-android — showcases the BlueStack Android SDK across multiple ad formats.

Prerequisites

Before You Start, BlueStack Ads requires minimum :

  • Android 5.0 (API level 21) or higher.
  • CompileSdkVersion at least 31.
  • Android Studio 4.0 or higher.

ExoPlayer Compatibility

BlueStack SDK uses AndroidX Media3 ExoPlayer for video ad playback. If your app also uses ExoPlayer, ensure compatibility:

  • BlueStack SDK v6.0.0+ uses androidx.media3:media3-exoplayer:1.9.2
  • If you use ExoPlayer in your app, use a compatible version to avoid runtime conflicts
  • For conflicts, align your ExoPlayer version with the SDK's Media3 version or use dependency resolution strategies in Gradle
astuce

If you encounter AbstractMethodError or similar runtime errors related to ExoPlayer, verify that all ExoPlayer/Media3 dependencies are aligned to compatible versions.

Configure your app

Installation using Gradle

1) In the settings.gradle of your project, you must declare there repositories :

dependencyResolutionManagement {
...
repositories {
...
google()
mavenCentral()
...
}
...
}

2) Add the following dependency to your app's build.gradle, and make sure the latest SDK is used:

Mandatory :

  • Bluestack Mediation SDK
dependencies {
// Bluestack SDK
implementation 'com.azerion:bluestack-sdk-core:6.0.0'
}

Update AndroidManifest.xml

Add the following permissions to your AndroidManifest.xml file inside the manifest tag but outside the <application> tag, if not done already:

<!-- Optional: Allows the SDK to access approximate location data based on cell towers to improve targeting. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Optional: Allows the SDK to access precise location data via GPS to improve targeting. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<!-- Optional: External storage is used for pre-caching features if available -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Add mediation partners

Mediation adapters are added as native dependencies in your app-level build.gradle. We recommend including all adapters by default so the SDK can serve from every available demand source — omit an adapter only if you have a specific reason not to ship it.

info

Recommended default: include every mediation adapter. The snippet below adds the full bundle, pinned to the v6 major line.

build.gradle
repositories {
google()
mavenCentral()
maven { url 'https://packagecloud.io/smartadserver/android/maven2' }
}

dependencies {
implementation 'com.azerion:bluestack-sdk-core:6.+'
implementation 'com.azerion:bluestack-mediation-bidding:6.+'
implementation 'com.azerion:bluestack-mediation-google:6.+'
implementation 'com.azerion:bluestack-mediation-equativ:6.+'
}

For Google Mobile Ads, also add your AdMob App ID to AndroidManifest.xml:

AndroidManifest.xml
<manifest>
<application>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>

For per-partner setup, version-specific adapters, ProGuard rules, and the compatibility matrix, see Supported Networks.

Initialize the BlueStack Ads SDK

Before loading ads, initialize the BlueStack Ads SDK by calling MobileAds.initialize(). Once the SDK completes initialization, it will provide an InitializationStatus instance through the initialization callback. This needs to be done only once.

import com.azerion.bluestack.MobileAds;
import com.azerion.bluestack.initialization.InitializationListener;
import com.azerion.bluestack.initialization.SDKInitializationStatus;

class MainActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
MobileAds.INSTANCE.initialize(this, "YOUR_APP_ID", initializationStatus -> {
initializationStatus.getMediationAdapterStatusMap().forEach((adNetworkName, adapterStatus) -> Log.d(TAG, "name: " + adapterStatus.getName() + "," + "state: " + adapterStatus.getState() + "," + "description: " + adapterStatus.getDescription()));
});
...
}
}

Note: If the BlueStack SDK fails to initialize, it will return an SDKInitializationStatus object containing an empty mediation adapter status map.