Unity Ads

Unity Level Play Ads Setup Log #1

  1. Link your Unity Project to a Unity Dashboard Project.

    Note

    We had already done this when setting up unity authentication.

  2. Sign your project up for for Unity Ads Monetization product in https://cloud.unity.com/

    1. Sign into https://cloud.unity.com/

    2. Click on the Products tab on the left hand side of the screen.

    3. Click on the Unity Ads Monetization product.

    4. Click on the Get Started button or Enable Ads button and fill out your company’s information.

    5. Under the stp for Meditation partner I chose the following default options

      • I plan to use Mediation

      • Mediation Partner: Unity LevelPlay

    6. Under the Project Info step for ad settings I selected the default option which was to start fresh.

    7. Under the setup step I selected the default option of bidding

    8. Under the store ID i indicated that My app is not live in an app store yet.

    9. With all of my information filled out I then was presented IDS for different platforms along with a set of instructions I will document in the next steps

# Follow the instructions in the Unity Editor LevelPlay integration.

  1. Go to Window > Package Manager

  2. Under the Packages Dropdown select Unity Registry and select the Ads Mediation package

  3. Click the Install button.

  4. Once the install is complete go to Ads Mediation > Integration Manager.

  5. Click the Update button next to ironSource and press the Import button on the popup. You may have to do this multiple times until it is fully updated.

  6. Install and Update the UnityAds adapter

  1. Set Up Unity LevelPlay

    1. Create an ironSource account at https://platform.ironsrc.com/partners/identity/signup

    2. On your ironSource homepage click the Add App button.

    3. Enter your app’s information.

    4. Enable add units (like Interstitial ads) that you want to display.

    5. If your app is on multiple platforms create a new app for each platform.

    6. Sign into https://cloud.unity.com/

    7. Click on the Products tab on the left hand side of the screen.

    8. Click on the Unity Ads Monetization product.

    9. Under Setup > API Management Generate your Level Play Service Account API Key and Monetization Stats API Access. Also take note of your Organization Core ID found under Setup > Organization Settings.

    10. On IronSource navigate to Setup > SDK networks and add the Unity Ads network.

    11. When setting up unity ads enter information for the API Key (Monetization Stats API) and enter organization Core ID. Make sure to enable Unity bidder auto setup which requires the Level Play Service Account API key and secret key you generated.

    12. For each app make sure to go to Settings > SDK Networks and under Unity Ads setup your add placements (you will need the App Store Game IDS found in the unity cloud monetization product under Settings > Game IDs and your Placement IDs which are found found in the unity cloud monetization product under Placements)

  2. Integrate the IronSource SDK into your unity project:

    1. Go to https://developers.is.com/ironsource-mobile/unity/unity-plugin/#step-1 for information about installing the ironSource Unity Package to your project.

  3. Implement ads

    1. Within the IronSource SDK is a IronSourceDemo scene and an IronSourceDemo script. Look inside the script to see examples of how to initialize the IronSource SDK and show advertisements.

  4. iOS 14 Readiness

    1. Update your plist with SKAdNetwork identifiers

      1. iOS versions 14+ requires you to include the ad network IDs for all of your ad networks in the Info.plist file.

      2. Visit https://developers.is.com/ironsource-mobile/unity/managing-skadnetwork-ids/ . Here ironSource has a tool that generates the SKAdNetworkItems text you can add to your info.plist file.

      3. Once you have copied the text, open your project’s XcodeWorkspace file and under your Unity-Iphone build open the file called Info.plist.

      4. Inside my unity project within a Editor folder I added a post process script that can add the string generated by ironSource to my info.plist file.

        #if UNITY_IOS
        using System.IO;
        using UnityEditor;
        using UnityEditor.Callbacks;
        using UnityEngine;
        
        // iOS versions 14+ require that you include the ad network IDs for all of your ad networks in the information property list file (Info.plist).
        // For more information visit https://developers.is.com/ironsource-mobile/unity/managing-skadnetwork-ids/
        
        public class AppendAdNetworkIDsToInfoPlistPostProcess : MonoBehaviour
        {
            [PostProcessBuild]
            public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
            {
                if (buildTarget == BuildTarget.iOS)
                {
                    string plistPath = pathToBuiltProject + "/Info.plist";
                    string plistContent = File.ReadAllText(plistPath);
        
                    // Your raw text
                    string rawText = "<key>MyKey</key><string>MyValue</string>";
        
                    // Append raw text to the end of the file, before the closing </dict> and </plist> tags
                    plistContent = plistContent.Replace("</dict>", rawText + "</dict>");
        
                    // Write back to the file
                    File.WriteAllText(plistPath, plistContent);
                }
            }
        }
        #endif
        
    2. Request Tracking Authorization

      1. With iOS 14, Apple introduced a new mechanism for privacy and ad tracking – the App Tracking Transparency (ATT) prompt.

      2. If you want to request user authorization to access app-related data, make sure to include the NSUserTrackingUsageDescription key in your app’s Information Property List (info.plist). You can update the <string> </string> section with your personal message to be displayed for your users as part of the ATT prompt.

        <key>NSUserTrackingUsageDescription</key>
        <string>Your Personalized Message here </string>
        
      3. Inside my unity project within a Editor folder I added a post process script that can add the above string to my info.plist file.

        #if UNITY_IOS
        using System.IO;
        using UnityEditor;
        using UnityEditor.Callbacks;
        using UnityEngine;
        
        public class RequestTrackingAuthorizationPostProcess : MonoBehaviour
        {
            [PostProcessBuild]
            public static void ChangeXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
            {
                if (buildTarget == BuildTarget.iOS)
                {
                    string plistPath = pathToBuiltProject + "/Info.plist";
                    string plistContent = File.ReadAllText(plistPath);
        
                    // Your raw text
                    string rawText = "<key>NSUserTrackingUsageDescription</key>\n<string>Your Personalized Message here </string>";
        
                    // Append raw text to the end of the file, before the closing </dict> and </plist> tags
                    plistContent = plistContent.Replace("</dict>", rawText + "</dict>");
        
                    // Write back to the file
                    File.WriteAllText(plistPath, plistContent);
                }
            }
        }
        #endif
        

Potential Errors

  • Xcode build Error

    Error

    ‘IronSource/IronSource.h’ file not found

    To fix this try:

    • If you have integrated unity ads go to Ads Mediation > Integration Manager. In the the ironSource row click the update button.

    • Go to https://developers.is.com/ironsource-mobile/unity/unity-plugin/#step-5. and download the IronSource.framework files. There should be instructions on the site on how to add these files to your project. for me I downloaded and added IronSource.framework into /Assets/Plugins/iOS

    • When opening the project in xcode use the .xcworkspace file in Xcode, not the .xcodeproj file. if you’re working on a project that uses CocoaPods or has multiple related sub-projects, you’ll typically be working with an .xcworkspace. If you’re working on a standalone project, you’ll be using an .xcodeproj.

    • Try cleaning your project (Product -> Clean Build Folder) and then rebuilding it.

    • Update MacOS and Xcode

  • Add Load Error

    Error

    Error loading Ad Unit: Interstitial_iOS - INVALID_ARGUMENT - adMarkup is missing; objectId is missing

    Error

    E/UnityAds: +[USRVApiSdk WebViewExposed_logError:callback:] (line:63) :: Header bidding load invocation failed: adMarkup is missing; objectId is missing

    To fix this try:

    • In Project Settings > Services > Ads Make sure Ads are switched on.

  • Duplicate Class Build Error

    Error

    Configure project :launcher WARNING: The option setting ‘android.enableR8=true’ is deprecated. It will be removed in version 5.0 of the Android Gradle plugin. You will no longer be able to disable R8 Task :unityLibrary:preBuild UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:preBuild UP-TO-DATE Task :launcher:preBuild UP-TO-DATE Task :unityLibrary:IronSource.androidlib:preBuild UP-TO-DATE Task :unityLibrary:IronSource.plugin:preBuild UP-TO-DATE Task :unityLibrary:preReleaseBuild UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:preReleaseBuild UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:packageReleaseRenderscript NO-SOURCE Task :launcher:extractProguardFiles UP-TO-DATE Task :unityLibrary:IronSource.plugin:preReleaseBuild UP-TO-DATE Task :unityLibrary:IronSource.androidlib:preReleaseBuild UP-TO-DATE Task :launcher:preReleaseBuild UP-TO-DATE Task :unityLibrary:packageReleaseRenderscript NO-SOURCE Task :unityLibrary:IronSource.androidlib:packageReleaseRenderscript NO-SOURCE Task :unityLibrary:IronSource.plugin:packageReleaseRenderscript NO-SOURCE Task :unityLibrary:GooglePlayGamesManifest.androidlib:compileReleaseRenderscript NO-SOURCE Task :unityLibrary:IronSource.plugin:compileReleaseRenderscript NO-SOURCE Task :unityLibrary:compileReleaseRenderscript NO-SOURCE Task :launcher:compileReleaseRenderscript NO-SOURCE Task :unityLibrary:IronSource.androidlib:compileReleaseRenderscript NO-SOURCE Task :unityLibrary:generateReleaseResValues UP-TO-DATE Task :launcher:generateReleaseResValues UP-TO-DATE Task :launcher:generateReleaseResources UP-TO-DATE Task :unityLibrary:generateReleaseResources UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:generateReleaseResValues UP-TO-DATE Task :unityLibrary:IronSource.plugin:generateReleaseResValues UP-TO-DATE Task :unityLibrary:IronSource.androidlib:generateReleaseResValues UP-TO-DATE Task :unityLibrary:IronSource.androidlib:generateReleaseResources UP-TO-DATE Task :unityLibrary:IronSource.plugin:generateReleaseResources UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:generateReleaseResources UP-TO-DATE Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE Task :unityLibrary:packageReleaseResources UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:packageReleaseResources UP-TO-DATE Task :unityLibrary:IronSource.androidlib:packageReleaseResources UP-TO-DATE Task :launcher:extractDeepLinksRelease UP-TO-DATE Task :unityLibrary:IronSource.plugin:packageReleaseResources UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:extractDeepLinksRelease UP-TO-DATE Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE Task :unityLibrary:IronSource.androidlib:extractDeepLinksRelease UP-TO-DATE Task :unityLibrary:processReleaseManifest UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:processReleaseManifest UP-TO-DATE Task :unityLibrary:IronSource.plugin:extractDeepLinksRelease UP-TO-DATE Task :unityLibrary:IronSource.androidlib:processReleaseManifest UP-TO-DATE Task :unityLibrary:IronSource.plugin:processReleaseManifest UP-TO-DATE Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE Task :unityLibrary:IronSource.androidlib:compileReleaseLibraryResources UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:compileReleaseLibraryResources UP-TO-DATE Task :unityLibrary:IronSource.plugin:compileReleaseLibraryResources UP-TO-DATE Task :unityLibrary:mergeReleaseShaders UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:mergeReleaseShaders UP-TO-DATE Task :unityLibrary:IronSource.androidlib:mergeReleaseShaders UP-TO-DATE Task :unityLibrary:IronSource.plugin:mergeReleaseShaders UP-TO-DATE Task :unityLibrary:IronSource.androidlib:compileReleaseShaders NO-SOURCE Task :unityLibrary:compileReleaseShaders NO-SOURCE Task :unityLibrary:generateReleaseAssets UP-TO-DATE Task :unityLibrary:IronSource.androidlib:generateReleaseAssets UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:compileReleaseShaders NO-SOURCE Task :unityLibrary:GooglePlayGamesManifest.androidlib:generateReleaseAssets UP-TO-DATE Task :unityLibrary:IronSource.plugin:compileReleaseShaders NO-SOURCE Task :unityLibrary:IronSource.androidlib:packageReleaseAssets UP-TO-DATE Task :unityLibrary:IronSource.plugin:generateReleaseAssets UP-TO-DATE Task :unityLibrary:IronSource.androidlib:compileReleaseAidl NO-SOURCE Task :unityLibrary:GooglePlayGamesManifest.androidlib:packageReleaseAssets UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:compileReleaseAidl NO-SOURCE Task :unityLibrary:IronSource.plugin:packageReleaseAssets UP-TO-DATE Task :unityLibrary:IronSource.plugin:compileReleaseAidl NO-SOURCE Task :unityLibrary:GooglePlayGamesManifest.androidlib:parseReleaseLocalResources UP-TO-DATE Task :unityLibrary:IronSource.androidlib:parseReleaseLocalResources UP-TO-DATE Task :unityLibrary:IronSource.plugin:parseReleaseLocalResources UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:generateReleaseRFile UP-TO-DATE Task :unityLibrary:IronSource.androidlib:generateReleaseRFile UP-TO-DATE Task :unityLibrary:IronSource.plugin:generateReleaseRFile UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:generateReleaseBuildConfig UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:javaPreCompileRelease UP-TO-DATE Task :unityLibrary:IronSource.androidlib:generateReleaseBuildConfig UP-TO-DATE Task :unityLibrary:IronSource.androidlib:javaPreCompileRelease UP-TO-DATE Task :unityLibrary:IronSource.plugin:generateReleaseBuildConfig UP-TO-DATE Task :unityLibrary:IronSource.plugin:javaPreCompileRelease UP-TO-DATE Task :unityLibrary:IronSource.androidlib:compileReleaseJavaWithJavac UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:compileReleaseJavaWithJavac UP-TO-DATE Task :unityLibrary:IronSource.androidlib:bundleLibCompileToJarRelease UP-TO-DATE Task :unityLibrary:IronSource.androidlib:mergeReleaseGeneratedProguardFiles UP-TO-DATE Task :unityLibrary:IronSource.androidlib:exportReleaseConsumerProguardFiles UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:bundleLibCompileToJarRelease UP-TO-DATE Task :unityLibrary:IronSource.plugin:compileReleaseJavaWithJavac UP-TO-DATE Task :unityLibrary:IronSource.plugin:bundleLibCompileToJarRelease UP-TO-DATE Task :unityLibrary:IronSource.plugin:mergeReleaseGeneratedProguardFiles UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:mergeReleaseGeneratedProguardFiles UP-TO-DATE Task :unityLibrary:IronSource.plugin:exportReleaseConsumerProguardFiles UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:exportReleaseConsumerProguardFiles UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:processReleaseJavaRes NO-SOURCE Task :unityLibrary:GooglePlayGamesManifest.androidlib:bundleLibResRelease NO-SOURCE Task :unityLibrary:IronSource.androidlib:processReleaseJavaRes NO-SOURCE Task :unityLibrary:IronSource.plugin:processReleaseJavaRes NO-SOURCE Task :unityLibrary:IronSource.plugin:bundleLibResRelease NO-SOURCE Task :unityLibrary:GooglePlayGamesManifest.androidlib:bundleLibRuntimeToJarRelease UP-TO-DATE Task :unityLibrary:IronSource.androidlib:bundleLibResRelease NO-SOURCE Task :unityLibrary:IronSource.androidlib:bundleLibRuntimeToJarRelease UP-TO-DATE Task :unityLibrary:IronSource.plugin:bundleLibRuntimeToJarRelease UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:mergeReleaseJniLibFolders UP-TO-DATE Task :unityLibrary:IronSource.androidlib:mergeReleaseJniLibFolders UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:mergeReleaseNativeLibs UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:stripReleaseDebugSymbols NO-SOURCE Task :unityLibrary:IronSource.androidlib:mergeReleaseNativeLibs UP-TO-DATE Task :unityLibrary:GooglePlayGamesManifest.androidlib:copyReleaseJniLibsProjectOnly UP-TO-DATE Task :unityLibrary:IronSource.androidlib:stripReleaseDebugSymbols NO-SOURCE Task :unityLibrary:IronSource.plugin:mergeReleaseJniLibFolders UP-TO-DATE Task :unityLibrary:IronSource.androidlib:copyReleaseJniLibsProjectOnly UP-TO-DATE Task :unityLibrary:IronSource.plugin:mergeReleaseNativeLibs UP-TO-DATE Task :unityLibrary:IronSource.plugin:stripReleaseDebugSymbols NO-SOURCE Task :unityLibrary:IronSource.plugin:copyReleaseJniLibsProjectOnly UP-TO-DATE Task :unityLibrary:packageReleaseAssets Task :unityLibrary:compileReleaseAidl NO-SOURCE Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE Task :unityLibrary:generateReleaseRFile UP-TO-DATE Task :unityLibrary:javaPreCompileRelease UP-TO-DATE Task :launcher:processReleaseManifest Task :launcher:mergeReleaseShaders UP-TO-DATE Task :launcher:compileReleaseShaders NO-SOURCE Task :launcher:generateReleaseAssets UP-TO-DATE Task :launcher:mergeReleaseAssets Task :launcher:checkReleaseDuplicateClasses FAILED Task :launcher:mergeReleaseResources

    Error

    Note: C:UnityProjectsTunnelTwisterV3LibraryBeeAndroidPrjIL2CPPGradleunityLibrarysrcmainjavacomunity3dplayerUnityPlayerActivity.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. FAILURE: Build failed with an exception. • What went wrong: Execution failed for task ‘:launcher:checkReleaseDuplicateClasses’. 1 exception was raised by workers: java.lang.RuntimeException: Duplicate class com.ironsource.unity.androidbridge.AndroidBridge found in modules IronSource-bridge.jar (IronSource-bridge.jar) and android-bridge.jar (android-bridge.jar) Duplicate class com.ironsource.unity.androidbridge.AndroidBridge$1 found in modules IronSource-bridge.jar (IronSource-bridge.jar) and android-bridge.jar (android-bridge.jar) Duplicate class com.ironsource.unity.androidbridge.AndroidBridge$2 found in modules IronSource-bridge.jar (IronSource-bridge.jar) and android-bridge.jar (android-bridge.jar) Duplicate class com.ironsource.unity.androidbridge.AndroidBridge$3 found in modules IronSource-bridge.jar (IronSource-bridge.jar) and android-bridge.jar (android-bridge.jar) Duplicate class com.ironsource.unity.androidbridge.AndroidBridge$4 found in modules IronSource-bridge.jar (IronSource-bridge.jar) and android-bridge.jar (android-bridge.jar) Duplicate class com.ironsource.unity.androidbridge.AndroidBridge$5 found in modules IronSource-bridge.jar (IronSource-bridge.jar) and android-bridge.jar (android-bridge.jar)

    The solution was found at https://forum.unity.com/threads/gradle-build-failed-duplicate-classes-ironsource.1506746/

    1. Delete the IronSource folder from my Assets Folder

    2. Go to the ironsource website (https://developers.is.com/ironsource-mobile/unity/unity-plugin/#step-1) and download the latest unity package.

    3. In unity go to Assets > Import Package > Custom Pacckage And import the ironsource package