Integration
The following page describes how to integrate the BidMachine SDK into your Android app.
The latest BidMachine SDK version is 3.3.0
. Release date is 21nd of March, 2025.
Install the SDK
- Minimum Android SDK version:
21
(5.0, Lollipop) - Minimum Gradle version:
7.2
- Minimum Android Gradle Plugin version:
7.1.0
Gradle
Add the following to your app-level build.gradle
file:
repositories {
// Add BidMachine Maven repository
maven {
url 'https://artifactory.bidmachine.io/bidmachine'
}
}
dependencies {
implementation "io.bidmachine:ads:3.3.0"
}
Set Java version to 8:
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
Device Advertising ID
In mobile apps, there are no cookies. Instead, Ad Manager uses user-resettable identifiers provided by the mobile device's operating system.
Typical advertising IDs are AdID (Android) and IDFA (Apple). Mobile advertising IDs allow developers and marketers to track activity for advertising purposes. They're also used to enhance serving and targeting capabilities.
Add Play Services Ads Identifier dependency:
implementation "com.google.android.gms:play-services-ads-identifier:18.2.0"
Network Security Configuration
Android 9.0 (API 28) blocks cleartext (non-HTTPS) traffic by default, which can prevent ads from being served correctly.
Failure to comply with this configuration may result in:
- Lower display rate
- Reduced fill rate
- Rendering errors
- Lower revenue
- Add a Network Security Configuration file to your
AndroidManifest.xml
:
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<application android:networkSecurityConfig="@xml/network_security_config" />
</manifest>
- In your
network_security_config.xml
file, add a base configuration that setscleartextTrafficPermitted
totrue
:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
</trust-anchors>
</base-config>
<debug-overrides>
<trust-anchors>
<certificates src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>
Initialize the SDK
Initialize the SDK and set your Source ID.
To get your SOURCE_ID
, visit our website or contact support.
- Java
- Kotlin
BidMachine.initialize(@NonNull Context, "<YOUR_SOURCE_ID>");
// or with InitializationCallback
BidMachine.initialize(@NonNull Context, "<YOUR_SOURCE_ID>", @Nullable InitializationCallback);
BidMachine.initialize(Context, "<YOUR_SOURCE_ID>")
// or with InitializationCallback
BidMachine.initialize(Context, "<YOUR_SOURCE_ID>", InitializationCallback?)