Freestar Ads Mediation for Unity Android

Freestar Ads Mediation - Unity Integration Guide for Android

Getting Started

Start displaying Freestar Ads in your Unity game today by following the simple steps below.


• Unity 2018 or newer

• Minimum Android API Level: 21 or higher


Please follow the instructions in order.

Make sure you switched to Android:

Import FreestarMediation unitypackage

Unity Player Settings

Import FreestarMediation unitypackage

Other settings: Minimum API Level: 21

Other settings: Target API Level: Highest Installed

Other settings: Api Compatability Level: .NET 4.x

Import FreestarMediation unitypackage

Publisher Settings: Custom Gradle Template ✅

Do Not Install Unity Ads

If you try to use Unity Ads Package with FreestarMediation, this will produce a build-time error because FreestarMediation already contains the Unity Ads library.

Import Custom Package

Download FreestarMediation.unitypackage

Next, we will import it into Unity as a Custom Package.

Import FreestarMediation unitypackage

Assets: Import Package: Custom Package

Import FreestarMediation unitypackage

Hit the Import button.

Resolve Android Dependencies

After importing our custom package, resolve Android dependencies via Assets.. External Dependency Manager... Android Resolver... Resolve.

Import FreestarMediation unitypackage

Manually Edit mainTemplate.gradle

Use your favorite file editor.

Edit [Unity Project Folder]/Assets/Plugins/Android/mainTemplate.gradle

Remove the top line:


Import FreestarMediation unitypackage

Add the following to the android root section:

    packagingOptions {

Save your changes to mainTemplate.gradle


Take a look at file [Unity Project Folder]/Assets/Plugins/Android/AndroidManifest.xml

Before going to production, you will need to modify the following values. For now, you can use what's already there.


        android:value="hO52kFtMvEo_AoeRzED0_XXfS1B1VQp9GW50yudJO-eUUTOmRBLl3c-2GyTevLNspll_fN5PLTbAHOakoTuHuP" />

    <meta-data android:name="" android:value="@integer/google_play_services_version"/>

Ready to Build Android

At this point, you should be able to build Android. If you encounter the following dialogs, hit 'YES'.

Import FreestarMediation unitypackage


Import FreestarMediation unitypackage

Freestar Initialization and Displaying Ads

Take a look at Assets/FreestarMediation/SampleFreestarAds.cs which was imported into your Unity project.

This working sample shows how to initialize, implement the ad listeners, and show banner, fullscreen Interstitial and Rewarded ads.
Assets/FreestarMediation/SampleFreestar.scene is also included.

Some publishers like to create a singleton class based on this sample. Utilize it as you see fit.

You can use the test key in SampleFreestarAds.cs

Privacy - Google Play Families Policy Compliance

If your game or app is officially under the Google Play Families program, Freestar provides such support:

FreeStarAds.setGoogleFamilyPolicyMode(, true); //If your app is designed only for children
//FreeStarAds.setGoogleFamilyPolicyMode( GoogleFamilyPolicyMode.mixed, false);  //If your app is designed for families with children

If your app is not officially under the Google Play Families program, then you do not need to set the Google Family Policy mode.

     * Only set Google Families Policy Mode if your app is required to comply with Google Play’s
     * Families Policy program.
     * @param googleFamilyPolicyMode app: the app is child-directed and will not receive
     *                               personalize or contextual ads.
     *                               mixed: the app is directed at mixed audiences.
     *                               none: (default) the app is not required to comply with Google
     *                                      Play's Family Policy
     * @param onlyNonPersonalizedAds true: if 'mixed' mode, then only personalized or contextual ads
     *                                     may be served.
     *                               false: if 'mixed' mode, then personalized or contextual ads
     *                                      may be served.
     *                               note:  if 'app' mode, then personalized or contextual ads
     *                                      may not be served regardless of this parameter.
    public static void setGoogleFamilyPolicyMode(GoogleFamilyPolicyMode googleFamilyPolicyMode,
                                                 boolean onlyNonPersonalizedAds)


Freestar SDK is GDPR compliant. In order for your users to be able to receive any ad fills in GDPR-affected countries, you, as a publisher, will need to implement a 3rd party Consent Management Platform (CMP). Freestar SDK will automatically detect user interactions with the CMP and act accordingly. Please see our Freestar GDPR Frequently Asked Questions for complete details and our recommended list of CMP service providers.


For Android, please use our test key XqjhRR for all your testing runs and enable test mode true. You will usually get 100% fill on all ad units. It is not recommended to use your production key for testing runs as that is strictly prohibited by our partners and bad things may happen to us on the business side of things.
Do not forget to uninstall and re-install your app when changing keys on your device.

When you are satisfied with your testing, please make a release build with your production key, and turn test mode off. Publish to store.

Automated Testing - Bypassing Ads

Are your automated tests failing after integrating Freestar Mediation Ads into your mobile application or game? Are you not sure it could be due to Freestar or something else? We have a feature called Automated Test Mode where you can run your automated tests to bypass Freestar or run Freestar in 'Limited Mediation' mode without making drastic changes to your code:

In your automated test suite code, before FreeStarAds.init is called:

FreeStarAds.setAutomatedTestMode( FreeStarAds.AutomatedTestMode.BYPASS_ALL_ADS )  
FreeStarAds.setAutomatedTestMode( FreeStarAds.AutomatedTestMode.LIMITED_MEDIATION )    //only runs AdMob & GAM

Again, this is only for your automated tests and not for production use.

Release Build

Final note when creating your release build: if you use proguard or minify, please add our proguard rules to your app proguard file.