Project Setup - cleveradssolutions/CAS-Android Wiki

  1. Link the project with CAS mediation settings
  2. Add CAS settings resources
  3. Add Google Ads App ID
  4. Migrate to AndroidX
  5. Method Count Reduction
  6. Set Java Version
  7. Manifest Permissions
  8. Network security configuration

Link the project with CAS mediation settings

To link your project with the mediation settings, you need to have a registered account and an application in the CAS system.

🌟 Note: If you haven't created an CAS account and registered the app yet, now's a great time to do so.
In a real app, it is important that you use your actual settings file and AdMob app ID.
If you just want to experiment or test the SDK, you can skip adding settings resources and use the sample app ID shown below.

  1. Sign In
  2. Select the Applications section on the right panel.
  3. Click the plus(+) button and follow the instructions on the form. It may take up to 30 minutes to register the app in the CAS system.
  4. After the registration completed, click the Action button in the row of your application


Add CAS settings resources

Add own settings file

CAS uses a mediation configuration caching system to handle unexpected situations. We recommend that you regularly update settings file to improve the stability of the mediation.

  1. Click the Download CAS settings button.
  2. A cas_settings[settings_id].json file will be downloaded. Please do not change the name of the file.
    The [settings_id] is the internal unique identifier of the resource.
  3. Drop the file into the src/res/raw/ folder of your project.

There can be several such settings files in one application if you use several Manager(Placement) IDs.

Add Google Ads App ID

⭐ If you don't want to use Google Ads (AdMob) then skip the step.
CAS assigns a new AdMob App ID for your application to the correct operation of all features.

⚠️ You cannot use your own identifier and must replace it with a new one generated by CAS system.

You can find your Admob App ID in the CAS UI:

  1. Click the Show AdMob App ID button.
  2. Copy the id from the form.
  3. Add a <meta-data> tag with android:name="" in your app's AndroidManifest.xml file.
  4. Insert AdMob app ID to android:value, surrounded by quotation marks, as shown below.
    <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->

Note that failure to add the <meta-data> tag as shown above results in a crash with the message:

The Google Mobile Ads SDK was initialized incorrectly.

Migrate to AndroidX

As of SDK 18.0.0, Google migrated from Android Support Libraries to Jetpack (AndroidX) Libraries. Refer to the Google Play services release notes for more information.

Due to this, we working with the AdMob adapter it’s required that your project migrates from Android Support Libraries to Jetpack Libraries (Android X) if you are using any. Please refer to Migrating to AndroidX for more information.

In case you can not migrate the project using this tool, you can use the following flags in, to build your project using AndroidX.


Method Count Reduction

Adding CAS SDK to your project includes many third party mediation libraries and may cause the 64K limit on methods that can be packaged in an Android DEX file to be breached.
Consider the following suggestions to reduce the total number of methods added to your project:

Enable ProGuard

You can enable ProGuard to shrink your project code. It will discard any unused classes at the time of compilation to make the total method count as small as possible. Enable it by setting minifyEnabled true in build.gradle for the appropriate buildTypes, and by providing the rules to keep the classes required by your project.

Enable MultiDEX

If you are still above a 65K method count, enabling MultiDEX may be the only solution provided by Google. You must only configure your project to MultiDex one time, but it will have an impact on build and app startup time.

Enable the MultiDEX support library to enable building your app correctly.

  1. Open your application build.gradle script.
  2. Modify the defaultConfig to mark your application as multidex enabled:
defaultConfig {
   multiDexEnabled true
  1. Add the following line to the dependencies element.
dependencies {
    implementation 'androidx.multidex:multidex:2.0.1'

Set Java Version

Our SDK requires for correct operation to determine the Java version in Gradle. Add the following line to the android element in your application build.gradle script.

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8

Manifest Permissions

Add the following permissions to your AndroidManifest.xml file inside the <manifest> tag but outside the <application> tag:

 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

VIBRATE permission is used for certain ads that vibrate during play. This is a normal level permission, so this permission just needs to be defined in the manifest to enable this ad feature.

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

ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permissions is not a mandatory permission, however, including it will enable accurate ad targeting.

 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 <!-- OR -->
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

WRITE_EXTERNAL_STORAGE permission is used for certain ads that allow the user to save a screenshot to their phone. Note that with this permission on devices running Android 6.0 (API 23) or higher, this permission must be requested from the user. See Requesting Permissions for more details.

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace"/> 

Sometimes permissions are included in the partner SDK’s internal AndroidManifest.
To remove a specific embedded permission (for example, ACCESS_COARSE_LOCATION), add the following tag to your top level AndroidManifest during integration:

  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" tools:node="remove" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove"/>

Network security configuration

Android 9.0 (API 28) blocks cleartext (non-HTTPS) traffic by default, which can prevent ads from serving correctly. Read more about Network security configuration

  1. Create res/xml/network_security_config.xml file, add base-config tag with sets cleartextTrafficPermitted attribute to true:
<?xml version="1.0" encoding="utf-8"?>
    <base-config cleartextTrafficPermitted="true">
            <certificates src="system" />
            <certificates src="user" />
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true"></domain>
  1. Add the network_security_config.xml file to your AndroidManifest.xml:

What’s Next?

Integrate mediation SDK to the dependencies section of your application: