Unity Cloud Build failed on mediation

Hello,
I’ve been using Unity Mediation for several months wthout any major problems.
But for about a week I’m experiencing a problem with building my android game on Unity Cloud Build with mediation package installed.

My Unity Cloud Build is set up to trigger clean Android builds every day, and suddenly the builds started to fail for no reason (I’ve not pushed any code changes to the branch that is used to start automatic builds).

Now, every time that I try to build Android target on Unity Cloud Build it fails on Mediation PreBuild script but the problem does not exist on my local machine.
Has anyone experienced the same issue, or know how to fix it?

I’m using Unity 2021.3.10f and mediation 1.0.4.

The Exception that triggers build cancelation:

113434: [2022-11-02T06:00:00Z - Unity] Uploading Crash Report
113435: [2022-11-02T06:00:00Z - Unity] EXCEPTION: BuildFailedException: Build canceled
113436: [2022-11-02T06:00:00Z - Unity] BuildFailedException: Build canceled
113437: [2022-11-02T06:00:00Z - Unity]   at Unity.Services.Mediation.Build.Editor.AndroidNativeDependenciesPreBuildCheck.DisplayIssueDetectedDialog (System.Boolean noDialog, System.String issue, Unity.Services.Mediation.Build.Editor.AndroidNativeDependenciesPreBuildCheck+UserAction action) [0x0009a] in BUILD_PATH/p\Library\PackageCache\com.unity.services.mediation@1.0.4\Editor\Build\PreBuild\AndroidNativeDependenciesPreBuildCheck.cs:144
113438: [2022-11-02T06:00:00Z - Unity]   at Unity.Services.Mediation.Build.Editor.AndroidNativeDependenciesPreBuildCheck.ValidateDependencies (System.Boolean noDialog) [0x0008f] in BUILD_PATH/p\Library\PackageCache\com.unity.services.mediation@1.0.4\Editor\Build\PreBuild\AndroidNativeDependenciesPreBuildCheck.cs:92
113439: [2022-11-02T06:00:00Z - Unity]   at Unity.Services.Mediation.Build.Editor.AndroidNativeDependenciesPreBuildCheck.OnPreprocessBuild (UnityEditor.Build.Reporting.BuildReport report) [0x0005e] in BUILD_PATH/p\Library\PackageCache\com.unity.services.mediation@1.0.4\Editor\Build\PreBuild\AndroidNativeDependenciesPreBuildCheck.cs:48
113440: [2022-11-02T06:00:00Z - Unity]   at UnityEditor.Build.BuildPipelineInterfaces+<>c__DisplayClass16_0.<OnBuildPreProcess>b__1 (UnityEditor.Build.IPreprocessBuildWithReport bpp) [0x00000] in <99feab6f3db6407493924fe4a179a95b>:0
113441: [2022-11-02T06:00:00Z - Unity]   at UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List`1[T] oneInterfaces, System.Action`1[T] invocationOne, System.Collections.Generic.List`1[T] twoInterfaces, System.Action`1[T] invocationTwo, System.Boolean exitOnFailure) [0x000ff] in <99feab6f3db6407493924fe4a179a95b>:0
113442: [2022-11-02T06:00:00Z - Unity] UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
113443: [2022-11-02T06:00:00Z - Unity] UnityEngine.DebugLogHandler:LogException(Exception, Object)
113444: [2022-11-02T06:00:00Z - Unity] UnityEngine.Logger:LogException(Exception, Object)
113445: [2022-11-02T06:00:00Z - Unity] UnityEngine.Debug:LogException(Exception)
113446: [2022-11-02T06:00:00Z - Unity] UnityEditor.Build.BuildPipelineInterfaces:InvokeCallbackInterfacesPair(List`1, Action`1, List`1, Action`1, Boolean)
113447: [2022-11-02T06:00:00Z - Unity] UnityEditor.Build.BuildPipelineInterfaces:OnBuildPreProcess(BuildReport)
113448: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[], Boolean)
113449: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[])
113450: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[])
113451: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
113452: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
113453: [2022-11-02T06:00:00Z - Unity] UnityEditor.CloudBuild.Builder:BuildPlayerDefault(BuildPlayerOptions)
113454: [2022-11-02T06:00:00Z - Unity] UnityEditor.CloudBuild.Builder:BuildPlayer(BuildPlayerOptions)
113455: [2022-11-02T06:00:00Z - Unity] UnityEditor.CloudBuild.Builder:Build()
113456: [2022-11-02T06:00:00Z - Unity]
113457: [2022-11-02T06:00:00Z - Unity] (Filename: Library/PackageCache/com.unity.services.mediation@1.0.4/Editor/Build/PreBuild/AndroidNativeDependenciesPreBuildCheck.cs Line: 144)
113458: [2022-11-02T06:00:00Z - Unity]
113459: [2022-11-02T06:00:00Z - Unity] DisplayProgressNotification: Build Failed
113460: [2022-11-02T06:00:00Z - Unity] ERROR: Error building Player: BuildFailedException: Build canceled
113461: [2022-11-02T06:00:00Z - Unity] Error building Player: BuildFailedException: Build canceled
2 Likes

I’ve managed to find a solution to this problem.

I had Android plugins directory added to .gitignore and it looks like AndroidNativeDependenciesPreBuildCheck.ValidateDependencies() prebuild script was called before Android dependecies was resolved, so addding android plugins directory to Git solved the issue.

2 Likes

Hello, I am running into the same error messages with mediation 1.0.4 on Unity 2020.3.30f1 building for android, however the above fix did not solve my issue. My project is using PlasticSCM as the source control and the ignore file does not include the android plugins folder or any of the file extensions except “private.0”. On my local, the dependencies seem to resolve just fine, however on unity cloud, the same stack trace as above occurs. One thing I had attempted was disabling the downloading of the android libraries during build via the external dependency manager as the .aar files are all included in the source control(and the metas). This caused the build time to significantly increase, only to fail with the same errors as before. I am unsure why the validation check is happening before the dependencies are resolved. Are there any specific settings on the android resolver that I’m missing?

I will update this thread tomorrow with more information regarding the packages I am using and the resolver’s settings.

If your build fails with an exception in the same lines of code as mine, then there are 2 possible reasons based on the dependecies validator code:

  • mediadion sdk .aar file is missing
  • mediation sdk .aar is outdated and version does not match mediation package version (it must match Major and Minor components of the version)
    In both cases it’s casued by validation being called too early, before Android dependencies are resolved, which was not the case several days ago on Unity Cloud Build when all of my builds have worked fine - even with plugin files not included in source control repository.
1 Like

So my mediation sdk .aar file seems to be 1.1.0 which does not make sense to me since the latest version that appears in my package manager is 1.0.4. This is what my resolver gives me on my local which is what ends up being used for the cloud builds.
Here is my AndroidResolverDependencies.xml:

<dependencies>
<packages>
<package>com.google.android.gms:play-services-auth:20+</package>
<package>com.google.android.gms:play-services-base:17.6.0</package>
<package>com.google.android.play:core:1.10.3</package>
<package>com.google.firebase:firebase-analytics:20.0.0</package>
<package>com.google.firebase:firebase-analytics-unity:8.7.0</package>
<package>com.google.firebase:firebase-app-unity:8.7.0</package>
<package>com.google.firebase:firebase-auth:21.0.1</package>
<package>com.google.firebase:firebase-auth-unity:8.7.0</package>
<package>com.google.firebase:firebase-common:20.0.0</package>
<package>com.google.firebase:firebase-database:20.0.3</package>
<package>com.google.firebase:firebase-database-unity:8.7.0</package>
<package>com.google.signin:google-signin-support:1.0.4</package>
<package>com.unity3d.mediation:mediation-sdk:[1.0,2.0[</package>
<package>com.unity3d.mediation:unityads-adapter:[1.0,2.0[</package>
</packages>
<files>
<file>Assets/Plugins/Android/androidx.annotation.annotation-1.2.0.jar</file>
<file>Assets/Plugins/Android/androidx.arch.core.core-common-2.0.0.jar</file>
<file>Assets/Plugins/Android/androidx.arch.core.core-runtime-2.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.asynclayoutinflater.asynclayoutinflater-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.browser.browser-1.4.0.aar</file>
<file>Assets/Plugins/Android/androidx.collection.collection-1.1.0.jar</file>
<file>Assets/Plugins/Android/androidx.concurrent.concurrent-futures-1.0.0.jar</file>
<file>Assets/Plugins/Android/androidx.coordinatorlayout.coordinatorlayout-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.core.core-1.2.0.aar</file>
<file>Assets/Plugins/Android/androidx.cursoradapter.cursoradapter-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.customview.customview-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.documentfile.documentfile-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.drawerlayout.drawerlayout-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.fragment.fragment-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.interpolator.interpolator-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.legacy.legacy-support-core-ui-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.legacy.legacy-support-core-utils-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.lifecycle.lifecycle-common-2.0.0.jar</file>
<file>Assets/Plugins/Android/androidx.lifecycle.lifecycle-extensions-2.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.lifecycle.lifecycle-livedata-2.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.lifecycle.lifecycle-livedata-core-2.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.lifecycle.lifecycle-process-2.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.lifecycle.lifecycle-runtime-2.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.lifecycle.lifecycle-service-2.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.lifecycle.lifecycle-viewmodel-2.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.loader.loader-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.localbroadcastmanager.localbroadcastmanager-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.print.print-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.slidingpanelayout.slidingpanelayout-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.startup.startup-runtime-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.swiperefreshlayout.swiperefreshlayout-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.tracing.tracing-1.0.0.aar</file>
<file>Assets/Plugins/Android/androidx.versionedparcelable.versionedparcelable-1.1.0.aar</file>
<file>Assets/Plugins/Android/androidx.viewpager.viewpager-1.0.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-ads-identifier-18.0.1.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-auth-20.3.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-auth-api-phone-18.0.1.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-auth-base-18.0.5.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-base-18.1.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-basement-18.1.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-measurement-21.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-measurement-api-21.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-measurement-base-21.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-measurement-impl-21.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-measurement-sdk-21.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-measurement-sdk-api-21.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-safetynet-18.0.1.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-stats-17.0.3.aar</file>
<file>Assets/Plugins/Android/com.google.android.gms.play-services-tasks-18.0.2.aar</file>
<file>Assets/Plugins/Android/com.google.android.play.core-1.10.3.aar</file>
<file>Assets/Plugins/Android/com.google.errorprone.error_prone_annotations-2.9.0.jar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-analytics-21.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-analytics-unity-8.7.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-annotations-16.1.0.jar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-appcheck-interop-16.1.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-app-unity-8.7.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-auth-21.1.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-auth-interop-20.0.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-auth-unity-8.7.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-common-20.2.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-components-17.0.1.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-database-20.1.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-database-collection-18.0.1.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-database-unity-8.7.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-installations-17.1.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-installations-interop-17.1.0.aar</file>
<file>Assets/Plugins/Android/com.google.firebase.firebase-measurement-connector-20.0.0.aar</file>
<file>Assets/Plugins/Android/com.google.guava.listenablefuture-1.0.jar</file>
<file>Assets/Plugins/Android/com.google.protobuf.protobuf-javalite-3.19.3.jar</file>
<file>Assets/Plugins/Android/com.google.signin.google-signin-support-1.0.4.aar</file>
<file>Assets/Plugins/Android/com.squareup.okhttp3.okhttp-4.6.0.jar</file>
<file>Assets/Plugins/Android/com.squareup.okio.okio-2.6.0.jar</file>
<file>Assets/Plugins/Android/com.unity3d.ads.unity-ads-4.4.1.aar</file>
<file>Assets/Plugins/Android/com.unity3d.mediation.mediation-adapter-1.1.0.aar</file>
<file>Assets/Plugins/Android/com.unity3d.mediation.mediation-logger-1.1.0.aar</file>
<file>Assets/Plugins/Android/com.unity3d.mediation.mediation-sdk-1.1.0.aar</file>
<file>Assets/Plugins/Android/com.unity3d.mediation.unityads-adapter-1.1.0.aar</file>
<file>Assets/Plugins/Android/com.unity3d.services.identifiers.unity-services-identifiers-1.0.0.aar</file>
<file>Assets/Plugins/Android/org.jetbrains.annotations-13.0.jar</file>
<file>Assets/Plugins/Android/org.jetbrains.kotlin.kotlin-stdlib-1.5.21.jar</file>
<file>Assets/Plugins/Android/org.jetbrains.kotlin.kotlin-stdlib-common-1.5.21.jar</file>
</files>
<settings>
<setting name="androidAbis" value="arm64-v8a,armeabi-v7a" />
<setting name="bundleId" value="com.dropbears.endline" />
<setting name="explodeAars" value="True" />
<setting name="gradleBuildEnabled" value="True" />
<setting name="gradlePropertiesTemplateEnabled" value="False" />
<setting name="gradleTemplateEnabled" value="False" />
<setting name="installAndroidPackages" value="True" />
<setting name="localMavenRepoDir" value="Assets/GeneratedLocalRepo" />
<setting name="packageDir" value="Assets/Plugins/Android" />
<setting name="patchAndroidManifest" value="True" />
<setting name="patchMainTemplateGradle" value="True" />
<setting name="projectExportEnabled" value="False" />
<setting name="useJetifier" value="True" />
</settings>
</dependencies>```

Hi @baily_unity ,

The native SDK (aar) will not (necessarily) have the same version as the Unity package (Inside the Package Manager), these are two separate concerns. What you have is normal.

The build is most likely failing due to resolution issues. Since you seem to have dependencies in your Plugins/Android folder, you most likely need to resolve your dependencies again (Assets > Mobile Dependency Resolver > Android Resolver > Resolve/Force Resolve).

We highly recommend using the mainTemplate.gradle file though instead of directly including the dependencies (Edit > Project Settings > Player > Android > Publishing Settings > Custom Main Gradle Template), make sure to clear out the binaries from the Plugins/Android folder though.

A quick update on this since I managed to get the Android build running (iOS isn’t playing nicely still). After enabling the custom mainTemplate gradle, clearing the binaries(.jar, .aar), and running the resolver again, the binaries re-added themselves somehow and the build was still crashing. For some miraculous reason, I decided to clear the binaries again and run the resolver again and it worked! Some setting must have been preventing the binaries from being deleted properly the first time it tried to resolve. I’m glad I attempted it again. The only reason I decided to do it again was that my coworker’s unity editor was somehow deleting the binaries automatically and would show up in his pushes without him realizing which gave a big hint that my resolver needed a little push before it knew what to do.

1 Like

according to the “com.unity.services.mediation@1.0.4” package SDK version verification code it HAS to be the same version. Thus having ads-mediation package 1.0.5 or 1.0.4 won’t work with SDK 1.1. Just because the version check is done by comparing strings.

        bool IsSdkCompatibleWithPackage()
        {
            var sdkPrefix = "com.unity3d.mediation.mediation-sdk-";
            var metaExtension = "meta";
            Path.Combine();
            var sdkInfo = MediationSdkInfo.GetSdkInfo();
            var pluginFiles = Directory.GetFiles(m_PluginFolder);
            var sdkFullFileName = pluginFiles.FirstOrDefault(x => Path.GetFileName(x).StartsWith(sdkPrefix) && !x.EndsWith(metaExtension));
            if (sdkFullFileName == null) return false;

            var sdkFileName = Path.GetFileNameWithoutExtension(sdkFullFileName);
            var sdkVersionString = sdkFileName.Replace(sdkPrefix, "");
            var sdkVersion = Version.Parse(sdkVersionString);
            var packageVersion = Version.Parse(sdkInfo.SdkVersion);
            //Logic subject to change at GA! Change to check major only.
            return sdkVersion.Major == packageVersion.Major && sdkVersion.Minor == packageVersion.Minor;
        }

even though “//Logic subject…” comment suggests that people were concerned about the problem back in days.

Is there a way to restrict the dependency to 1.0 only?

It seems like the problem was introduced by changing the list of external package repositories.
The newer repos seems to be providing SDK 1.1 while older set of are providing mediation SDK 1.0.

I’m saying that is because on one Unity desktop resolving packages always return SDK 1.0. (But it was setup a several months ago).
On the newer Unity desktop, resolving packages returns 1.1.
I do presume that the older machine has repos information cached, and doesn’t try attempt to query newer repositories and that’s why it works and the proper SDK 1.0 is pulled.

Maybe I could share “caching” info from the older station to the newer one
— update:
according to Gradle log “maven2” (Google) repo has mitigration-sdk 1.0
“BintrayJCenter” and “MavenRepo” (apache) have mitigation-sdk 1.1

and that worked!
i did copy “C:\Users%username%.gradle” folder from the old pc to the new pc and Unity has no problems “resolving” to the proper mediation-sdk of 1.0.0 instead of 1.1.0

Looking at the problem reporting of (invalid SDK version) related to ads-mediation , it seems like the problem has started in Nov 2022. Might indicate the time of the update took place on the repositories.

Same here. Same problems. Mediation package want 1.0.0. But get 1.1.0
You cat see this in IsSdkCompatibleWithPackage method

This problem iget on new machine
@DeclanMcPartlin - can you help with this

1 Like