Skip to content

Include Android

Str4tos edited this page Jul 14, 2025 · 33 revisions

The Clever Ads Solutions Unity plugin is distributed with the EDM4U library. This library is intended for use by any Unity plugin that requires access to Android specific libraries (e.g., AARs) or iOS CocoaPods. It provides Unity plugins the ability to declare dependencies, which are then automatically resolved and copied into your Unity project.

Configure Gradle

Using EDM4U, you will be able to avoid downloading the Android artifacts into your project. Instead, the artifacts will be added to your gradle file during the compilation. To enable this process, follow these steps:

  • Go to: Player Settings > Publishing Settings > Build
  • Custom Main Gradle Template to configure third party dependencies.
  • Custom Base Gradle Template to update Gradle plugin with fix support Android 11.
    You can read more about fix Gradle plugin with support Android 11 on the Android Deleveloper page.
  • Custom Gradle Properties Template to use Jetfier by EDM4U.
  • Custom Main Manifest to modify application manifest.
  • Custom Gradle Settings Template to include maven repositories
    Support Android Gradle Plugin version 7.1.0+

image

Configure EDM4U

  • Go to: Assets > External Dependency Manager > Android > Settings
  • Patch mainTemplate.gradle
    The mainTemplate.gradle file will be patched with dependencies managed by the Android Resolver.
  • Save your changes, by pressing OK

In the Unity editor, select Assets > External Dependency Manager > Android Resolver > Resolve. The Unity External Dependency Manager library will append dependencies to mainTemplate.gradle of your Unity app.

Execute events on Unity Thread

Advertising events for the Android runtime are queued to be called during the next Update() cycle. This behavior is safe for using UnityEngine components in advertising events. However, because Unity does not call Update while displaying fullscreen ads, all ad events will only be triggered after closing the fullscreen ad and returning to the Unity game.

If you want to receive callbacks from the ad without waiting for the ad to close, you can disable the isExecuteEventsOnUnityThread property in the settings. Enabled by default.

CAS.MobileAds.settings.isExecuteEventsOnUnityThread = false;

You will also need to use CAS.EventExecutor.Add(Action) to access Unity Engine components, where Action will be executed during the next Update() cycle.

Note

isExecuteEventsOnUnityThread property used Android runtime only and enabled by default.

(Optional) Override Gradle versions

CAS have option to override Gradle Wrapper and Android Gradle Plugin versions in CAS Other Settings. The specified versions will be pre-set for the Android Studio project without requiring manual project export.

Leave the fields empty to use unity original Gradle versions.

Gradle Wrapper version

Supported strings with full https url or just version number, for example 7.2 or full url:

https\://services.gradle.org/distributions/gradle-7.2-bin.zip

Android Gradle Plugin version

Supported version strings only, for example 4.2.2.

Note

Please ensure compatibility of all build components when using this option. See official Gradle and Android Gradle Plugin compatibility table here


🔗 Done! What’s Next?

Clone this wiki locally