Home - cleveradssolutions/CAS-Android GitHub Wiki

Prerequisites
Minimum SDK version 21
Compile SDK version 34
Gradle wrapper 6.7.1+
Gradle plugin 4.2.2+

Add Maven repositories

In your root-level (project-level) Gradle file (<project>/settings.gradle), add the following repositories block so that Gradle can download the artifacts of ad networks:

dependencyResolutionManagement {
  repositories {
    google()  
    mavenCentral()  
    maven {  
        name = "IronSourceAdsRepo"  
        url = "https://android-sdk.is.com/"  
        content { it.includeGroup("com.ironsource.sdk") }  
    }  
    maven {  
        name = "MintegralAdsRepo"  
        url = "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea"  
        content { it.includeGroup("com.mbridge.msdk.oversea") }  
    }  
    maven {  
        name = "PangleAdsRepo"  
        url = "https://artifact.bytedance.com/repository/pangle"  
        content { it.includeGroup("com.pangle.global") }  
    }  
    maven {  
        name = "SuperAwesomeAdsRepo"  
        url = "https://aa-sdk.s3-eu-west-1.amazonaws.com/android_repo"  
        content { it.includeGroup("tv.superawesome.sdk.publisher") }  
    }  
    maven {  
        name = "ChartboostAdsRepo"  
        url = "https://cboost.jfrog.io/artifactory/chartboost-ads/"  
        content { it.includeGroup("com.chartboost") }  
    }
  }
}
Closed beta ads repos

Read more about Closed beta ads partners on Advanced integration page.

    maven {  
        name = "OguryAdsRepo"  
        url = "https://maven.ogury.co"  
        content {  
            it.includeGroup("co.ogury")  
            it.includeGroup("co.ogury.module")  
        }  
    }  
    maven {  
        name = "LoopMeAdsRepo"  
        url = "https://jitpack.io"  
        content { it.includeGroup("com.github.loopme.android-united-sdk") }  
    }
    maven {  
        name = "MadexAdsRepo"  
        url = "https://sdkpkg.sspnet.tech"  
        content {  
            it.includeGroup("sspnet.tech")  
            it.includeGroup("sspnet.tech.adapters")  
        }  
    }
    maven {  
        name = "SmaatoAdsRepo"  
        url = "https://s3.amazonaws.com/smaato-sdk-releases/"  
        content { it.includeGroup("com.smaato.android.sdk") }  
    }  

Note

If your project is using Gradle version below 7.0, the repositories block should be added to the allprojects block in the root-level (project-level) build.gradle file.

Add CAS SDK

You can integrate CAS to your Android app using one of the following options:

  • Option 1(recommended) Use the CAS Gradle plugin setup workflow.
  • Option 2: Use the default Gradle setup (may require additional configuration).

Option 1: Plugin integration

The CAS SDK provide a Gradle Plugin to simplify and automate certain integration steps. Our plugin will automatically add mediated network dependencies to your project, which you configure in an cas block.

In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle), add the CAS services plugin inside the plugins block.

plugins {
    id("com.cleveradssolutions.gradle-plugin") version "3.9.4"
}

cas {
    // Plugin configuration
}

Note

To receive release updates Subscribe

If you are integrating the plugin into the module (library-level) then also define the cas.casId property.

cas {
    casId = "com.yourcompany.yourproject"
}
What is CAS ID?

In most cases, a casId is the same as your application package name.

  • package name uniquely identifies your app on the device and in the Google Play Store.
  • The package name value is case-sensitiv and is often referred to as an APPLICATION_ID.
  • Find your app's package name in your module (app-level) Gradle file, usually app/build.gradle (example package name: com.yourcompany.yourproject).

Option 2: No plugin integration

You have the option not to use the Gradle Plugin; however, this will require additional configuration steps for your project.

Add dependency to build.gradle file.

dependencies {
   implementation("com.cleveradssolutions:cas-sdk:3.9.4")
}

Important

If you are not using the CAS Gradle plugin, please expand the No plugin integration instructions for each step.
You also need to manually link your project to improve advertising effectiveness.

Add Ads Solution

CAS is a mediation platform that requires selecting desired ad networks for monetizing your application.

You can choose one of the ready-made solutions or integrate each adapter separately. Such solutions do not require you to add each network adapter separately.

If you already know what to expect from ad networks and are ready to select the set of adapters yourself, after completing the steps on this page, please refer to the Advanced Integration page. Or consult your account manager for assistance.

Add one of the following lines of the standard Clever Ads Solution to module build.gradle file.

An Optimal Ads Solution

Contains a number of stable ads networks that are recommended for use in most applications:
Google Ads, Unity Ads, IronSource, LiftoffMonetize, InMobi, Yandex Ads, Mintegral, Pangle, Chartboost, DTExchange, AppLovin, AudienceNetwork, Bigo, CASExchange.

cas {
    includeOptimalAds = true
}
No plugin integration
implementation("com.cleveradssolutions:cas:3.9.4")

Warning

Please note that some ad networks require you to do Additional integration steps: Google AdMob, Meta AudienceNetwork, Yandex Mobile Ads.

A Families Ads Solution

Designed for applications tagged at a children's audience and fully compatible with the Google Play Families Policies. Contains:
Google Ads, Unity Ads, IronSource, LiftoffMonetize, InMobi, Chartboost, DTExchange, Kidoz, SuperAwesome.

cas {
    includeFamiliesAds = true
}
No plugin integration
implementation("com.cleveradssolutions:cas-families:3.9.4")

Enable code minification

Enabling minifyEnabled is a crucial step in optimizing your mobile application, especially when integrating ad mediation SDKs that augment your codebase's size. By leveraging code minification, you not only reduce the overall footprint of your app but also enhance its performance, security, and compatibility.

android {
    buildTypes {  
        release {  
            minifyEnabled true
            ...
        }  
    }
    ...
}

Note

The CAS SDK and adapters come bundled with the required ProGuard rules in the AARs. Therefore, you do not need to add any additional ProGuard rules to your project.

Google Advertising Identifier

The Advertising ID is a unique, user-resettable, and user-deletable ID for advertising, provided by Google Play services.

cas {
    useAdvertisingId = true
}

Note

Your must define cas.useAdvertisingId = false

  • If the target audience for app only includes children as described in the Families Policy
  • If app are building for devices that do not utilize Google Play Services, skip this step. For example Amazon or Huawei.
No plugin integration

Add the Play Services Ads identifier into the dependencies block to allow GAID information to be retrieved.

implementation("com.google.android.gms:play-services-ads-identifier:18.0.1")

Additionally, apps will need to declare a Google Play Services normal permission in the AndroidManifest.xml file as follows:

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

Some SDKs, such as the Google Mobile Ads SDK may already declare this permission in the SDK’s library manifest.

If your app uses these SDKs as dependencies, the AD_ID permission from the SDK’s library manifest will be merged with your app’s main manifest by default, even if you don’t explicitly declare the permission in your app’s main manifest.

To prevent the permission from getting merged into your app by including the following element in your manifest:

<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>

Java version compatibility

If you support Android SDK below 26, you must add the following snippet to the Android section:

android {
    compileOptions {
       sourceCompatibility JavaVersion.VERSION_1_8
       targetCompatibility JavaVersion.VERSION_1_8
    }
    ...
}

Optional permissions 

The following permissions are not required for our SDK or 3rd-party SDKs to function, but including them in your AndroidManifest.xml may result in improved eCPM and user experience.

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>  
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

🔗 Done! What’s Next?

  • Those ad networks that are not included in standard solutions can be added separately, read more about Advanced integration.
⚠️ **GitHub.com Fallback** ⚠️