Infinity Ads SDK Integration Guide for Android
Get started!
The Infinity SDK installation setup is a breeze.
Unlike other ad networks and mediation partners Infinity doesn't send you in circles or deep deep deep link simple valuable resources when trying to setup a proper monetization platform. Hence why Infinity was born.
Introduction
This page provides detailed instructions on how to set up Infinities SDK in their projects. Follow these steps carefully to ensure a smooth integration and maximize your monetization potential. For API Documentation please follow here, we have a added the infinity API on to the sCloud Developer documentation
The Infinity Ads SDK offers a variety of ad formats and powerful features designed to help you earn more revenue while providing a seamless user experience.
SDK Setup Instructions
Follow these steps to integrate the Infinity Ads SDK into your Android project. Ensure you have Android Studio installed and a basic Android project set up.
1 Add Dependency (Gradle)
Add the following dependency to your app's build.gradle
file (usually located in the app/
directory):
dependencies {
implementation 'com.example.infinityads:infinity-ads-sdk:1.0.0' // Replace with the actual SDK dependency version
// Ensure you also include any other necessary dependencies, such as Google Play Services Ads if required by the SDK
implementation 'com.google.android.gms:play-services-ads:23.0.0' // Example: Google Play Services Ads
}
After adding the dependency, make sure to sync your Gradle project by clicking "Sync Now" in the Android Studio notification or by going to File > Sync Project with Gradle Files.
2 Initialize the SDK
Initialize the SDK in your custom Application
class. If you don't have one, create a new Java/Kotlin class that extends android.app.Application
and register it in your AndroidManifest.xml
.
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// InfinityMediationSDK.enableTestAds(true);//remove this line in production, this line will show TEST ADS ONLY.
InfinityAdsSdk.initialize(this, "YOUR_APP_ID"); // Replace "YOUR_APP_ID" with your actual App ID provided by Infinity Ads
}
}
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// InfinityMediationSDK.enableTestAds(true)//remove this line in production, this line will show TEST ADS ONLY.
InfinityAdsSdk.initialize(this, "YOUR_APP_ID") // Replace "YOUR_APP_ID" with your actual App ID
}
}
Remember to register your custom Application
class in your AndroidManifest.xml
file within the <application>
tag:
<application
android:name=".MyApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApp">
<!-- Other application configurations -->
</application>
3 Add Internet Permission
The Infinity Ads SDK requires internet access to fetch and display ads. Ensure you have the internet permission declared in your AndroidManifest.xml
file:
<uses-permission android:name="android.permission.INTERNET" />
4 Implement Ad Placement
The implementation details for displaying ads will depend on the specific ad format you choose to integrate (e.g., Banner, Interstitial, Rewarded). Here's a general example for initializing and preparing an ad placement within an Activity or Fragment:
import com.example.infinityads.AdPlacement;
import com.example.infinityads.AdPlacementListener;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
public class MainActivity extends AppCompatActivity {
private AdPlacement bannerAdPlacement;
private FrameLayout bannerAdContainer;
private static final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bannerAdContainer = findViewById(R.id.banner_ad_container); // Assuming you have a FrameLayout in your layout
// Create an AdPlacement instance for a banner ad
bannerAdPlacement = InfinityAdsSdk.createBannerAdPlacement(this, "YOUR_BANNER_AD_UNIT_ID"); // Replace with your Banner Ad Unit ID
// Set a listener to receive ad events
bannerAdPlacement.setAdPlacementListener(new AdPlacementListener() {
@Override
public void onAdLoaded(AdPlacement adPlacement) {
Log.d(TAG, "Banner ad loaded successfully.");
// Add the ad view to your container
View adView = bannerAdPlacement.getAdView();
if (adView != null) {
bannerAdContainer.addView(adView);
}
}
@Override
public void onAdFailedToLoad(AdPlacement adPlacement, String error) {
Log.e(TAG, "Banner ad failed to load: " + error);
}
@Override
public void onAdOpened(AdPlacement adPlacement) {
Log.d(TAG, "Banner ad opened.");
}
@Override
public void onAdClosed(AdPlacement adPlacement) {
Log.d(TAG, "Banner ad closed.");
}
@Override
public void onAdClicked(AdPlacement adPlacement) {
Log.d(TAG, "Banner ad clicked.");
}
// Implement other listener methods for specific ad formats (e.g., onRewarded)
});
// Load the ad
bannerAdPlacement.loadAd();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (bannerAdPlacement != null) {
bannerAdPlacement.destroy();
bannerAdPlacement = null;
}
}
}
import com.example.infinityads.AdPlacement
import com.example.infinityads.AdPlacementListener
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.util.Log
import android.view.View
import android.widget.FrameLayout
class MainActivity : AppCompatActivity() {
private var bannerAdPlacement: AdPlacement? = null
private lateinit var bannerAdContainer: FrameLayout
private val TAG = "MainActivity"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
bannerAdContainer = findViewById(R.id.banner_ad_container) // Assuming you have a FrameLayout
// Create an AdPlacement instance for a banner ad
bannerAdPlacement = InfinityAdsSdk.createBannerAdPlacement(this, "YOUR_BANNER_AD_UNIT_ID") // Replace with your Banner Ad Unit ID
// Set a listener to receive ad events
bannerAdPlacement?.setAdPlacementListener(object : AdPlacementListener {
override fun onAdLoaded(adPlacement: AdPlacement) {
Log.d(TAG, "Banner ad loaded successfully.")
// Add the ad view to your container
val adView = adPlacement.adView
adView?.let { bannerAdContainer.addView(it) }
}
override fun onAdFailedToLoad(adPlacement: AdPlacement, error: String) {
Log.e(TAG, "Banner ad failed to load: $error")
}
override fun onAdOpened(adPlacement: AdPlacement) {
Log.d(TAG, "Banner ad opened.")
}
override fun onAdClosed(adPlacement: AdPlacement) {
Log.d(TAG, "Banner ad closed.")
}
override fun onAdClicked(adPlacement: AdPlacement) {
Log.d(TAG, "Banner ad clicked.")
}
// Implement other listener methods for specific ad formats
})
// Load the ad
bannerAdPlacement?.loadAd()
}
override fun onDestroy() {
super.onDestroy()
bannerAdPlacement?.destroy()
bannerAdPlacement = null
}
}
Remember to replace "YOUR_BANNER_AD_UNIT_ID"
with the actual Ad Unit ID provided by Infinity Ads for the banner ad placement. You'll need to adapt this code based on the ad format you are implementing. Refer to the Infinity Ads SDK documentation for specific instructions on implementing Interstitial, Rewarded, and other ad formats.
Ad Campaigns
This section provides information on how to set up and manage your ad campaigns with in our platform.
Campaign Setup
Details on creating new campaigns, defining campaign goals, and configuring basic settings.
Budgets
Information on managing campaign budgets, setting daily and total spending limits.
Targeting
Guidance on how to target specific user demographics, interests, and geographic locations for your campaigns.
Reporting
Explanation of the reporting features available to track campaign performance, impressions, clicks, and conversions.
Ad Units
Learn about the different ad unit formats supported by the Infinity Ads SDK and how to create them in the Infinity Ads dashboard.
Creating Ad Units
Step-by-step instructions on how to create new ad units (e.g., Banner, Interstitial, Rewarded) through your Infinity Ads account.
Interstitial Ads
Details on implementing full-screen interstitial ads, frequency capping, and user experience considerations.
Rewarded Ads
Guidance on implementing rewarded video ads, setting up rewards, and server-side verification (if applicable).
Native Ads
Explanation of native ad implementation, customizing ad layouts to match your app's design, and handling ad assets.
Best Practices
Tips and recommendations for maximizing ad revenue, optimizing user experience, and avoiding common integration pitfalls.
- Ad Placement: Place ads strategically without disrupting the user flow.
- Frequency Capping: Avoid showing too many interstitial ads to the same user in a short period.
- User Experience: Ensure ads are clearly distinguishable from app content.
- Testing: Thoroughly test your ad integration on various devices and network conditions.
- SDK Updates: Keep your SDK updated to the latest version for bug fixes and new features.
Troubleshooting
Common issues and their solutions during the SDK integration process.
- Ads Not Showing: Check your App ID, Ad Unit IDs, internet permission, and logcat for errors.
- SDK Initialization Errors: Ensure the SDK is initialized correctly in your Application class.
- Gradle Sync Issues: Verify your
build.gradle
dependencies and try syncing again. - Layout Issues: Ensure your ad container views are correctly sized and positioned.
FAQ
Frequently asked questions about the Infinity Ads SDK.
- Q: What ad formats are supported? A: Banner, Interstitial, Rewarded, and Native ads.
- Q: How do I get my App ID and Ad Unit IDs? A: You can find these in your Infinity Ads dashboard after creating an account and adding your app.
- Q: Is test mode available? A: Yes, refer to the SDK initialization section for enabling test ads. Remember to remove test mode in production.
- Q: How often should I show interstitial ads? A: It's recommended to implement frequency capping to avoid disrupting user experience. A common practice is to show them after natural breaks in the app flow (e.g., after completing a game level).
Contact Support
If you encounter any issues or have further questions, please don't hesitate to contact our support team at support@infinityads.com.