Search Unity

Bug Unity Cloud Build failed on mediation

Discussion in 'Unity Mediation' started by delait-7, Nov 2, 2022.

  1. delait-7

    delait-7

    Joined:
    Nov 15, 2019
    Posts:
    6
    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:

    Code (CSharp):
    1. 113434: [2022-11-02T06:00:00Z - Unity] Uploading Crash Report
    2. 113435: [2022-11-02T06:00:00Z - Unity] EXCEPTION: BuildFailedException: Build canceled
    3. 113436: [2022-11-02T06:00:00Z - Unity] BuildFailedException: Build canceled
    4. 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
    5. 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
    6. 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
    7. 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
    8. 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
    9. 113442: [2022-11-02T06:00:00Z - Unity] UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
    10. 113443: [2022-11-02T06:00:00Z - Unity] UnityEngine.DebugLogHandler:LogException(Exception, Object)
    11. 113444: [2022-11-02T06:00:00Z - Unity] UnityEngine.Logger:LogException(Exception, Object)
    12. 113445: [2022-11-02T06:00:00Z - Unity] UnityEngine.Debug:LogException(Exception)
    13. 113446: [2022-11-02T06:00:00Z - Unity] UnityEditor.Build.BuildPipelineInterfaces:InvokeCallbackInterfacesPair(List`1, Action`1, List`1, Action`1, Boolean)
    14. 113447: [2022-11-02T06:00:00Z - Unity] UnityEditor.Build.BuildPipelineInterfaces:OnBuildPreProcess(BuildReport)
    15. 113448: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[], Boolean)
    16. 113449: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayerInternal(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[])
    17. 113450: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayer(String[], String, String, BuildTargetGroup, BuildTarget, Int32, BuildOptions, String[])
    18. 113451: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
    19. 113452: [2022-11-02T06:00:00Z - Unity] UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
    20. 113453: [2022-11-02T06:00:00Z - Unity] UnityEditor.CloudBuild.Builder:BuildPlayerDefault(BuildPlayerOptions)
    21. 113454: [2022-11-02T06:00:00Z - Unity] UnityEditor.CloudBuild.Builder:BuildPlayer(BuildPlayerOptions)
    22. 113455: [2022-11-02T06:00:00Z - Unity] UnityEditor.CloudBuild.Builder:Build()
    23. 113456: [2022-11-02T06:00:00Z - Unity]
    24. 113457: [2022-11-02T06:00:00Z - Unity] (Filename: Library/PackageCache/com.unity.services.mediation@1.0.4/Editor/Build/PreBuild/AndroidNativeDependenciesPreBuildCheck.cs Line: 144)
    25. 113458: [2022-11-02T06:00:00Z - Unity]
    26. 113459: [2022-11-02T06:00:00Z - Unity] DisplayProgressNotification: Build Failed
    27. 113460: [2022-11-02T06:00:00Z - Unity] ERROR: Error building Player: BuildFailedException: Build canceled
    28. 113461: [2022-11-02T06:00:00Z - Unity] Error building Player: BuildFailedException: Build canceled
     
    ooxcit and dpendrak like this.
  2. delait-7

    delait-7

    Joined:
    Nov 15, 2019
    Posts:
    6
    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.
     
    dpendrak and DeclanMcPartlin like this.
  3. baily_unity

    baily_unity

    Joined:
    Dec 1, 2021
    Posts:
    3
    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.
     
  4. delait-7

    delait-7

    Joined:
    Nov 15, 2019
    Posts:
    6
    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.
     
    dpendrak likes this.
  5. baily_unity

    baily_unity

    Joined:
    Dec 1, 2021
    Posts:
    3
    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>
     
  6. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    146
    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.
     
  7. baily_unity

    baily_unity

    Joined:
    Dec 1, 2021
    Posts:
    3
    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.
     
    WaffleChicken likes this.
  8. skalogryz

    skalogryz

    Joined:
    Nov 28, 2021
    Posts:
    2
    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.
    Code (CSharp):
    1.         bool IsSdkCompatibleWithPackage()
    2.         {
    3.             var sdkPrefix = "com.unity3d.mediation.mediation-sdk-";
    4.             var metaExtension = "meta";
    5.             Path.Combine();
    6.             var sdkInfo = MediationSdkInfo.GetSdkInfo();
    7.             var pluginFiles = Directory.GetFiles(m_PluginFolder);
    8.             var sdkFullFileName = pluginFiles.FirstOrDefault(x => Path.GetFileName(x).StartsWith(sdkPrefix) && !x.EndsWith(metaExtension));
    9.             if (sdkFullFileName == null) return false;
    10.  
    11.             var sdkFileName = Path.GetFileNameWithoutExtension(sdkFullFileName);
    12.             var sdkVersionString = sdkFileName.Replace(sdkPrefix, "");
    13.             var sdkVersion = Version.Parse(sdkVersionString);
    14.             var packageVersion = Version.Parse(sdkInfo.SdkVersion);
    15.             //Logic subject to change at GA! Change to check major only.
    16.             return sdkVersion.Major == packageVersion.Major && sdkVersion.Minor == packageVersion.Minor;
    17.         }
    18.  
    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
     
    Last edited: Dec 5, 2022
  9. skalogryz

    skalogryz

    Joined:
    Nov 28, 2021
    Posts:
    2
    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.
     
    Last edited: Dec 5, 2022
  10. ViliamVolosV

    ViliamVolosV

    Joined:
    Feb 12, 2013
    Posts:
    19
    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
     
    Last edited: Dec 8, 2022
    ooxcit likes this.