Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity Ads script Causing Builds To Fail? o.O

Discussion in 'Unity Build Automation' started by UsernameZero, Dec 30, 2016.

  1. UsernameZero

    UsernameZero

    Joined:
    Feb 19, 2015
    Posts:
    29
    Hey all, my most recent project is nearing completion and now I would like to implement Unity ads the problem is doings so causes cloud build to fail, I noticed with ads turned on it builds fine but when I use the example code to show the ads it fails.

    Here is the example script I'm using with 2 variables and of course the reward code, in the editor it works fine, no errors at all.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Advertisements;
    5.  
    6. public class AdsManager : MonoBehaviour
    7. {
    8.  
    9.     public int Bait;
    10.     private BaitScoreManager bsm;
    11.  
    12.     public void ShowRewardedAd()
    13.     {
    14.         if (Advertisement.IsReady("rewardedVideo"))
    15.         {
    16.             var options = new ShowOptions { resultCallback = HandleShowResult };
    17.             Advertisement.Show("rewardedVideo", options);
    18.         }
    19.     }
    20.  
    21.     private void HandleShowResult(ShowResult result)
    22.     {
    23.         switch (result)
    24.         {
    25.             case ShowResult.Finished:
    26.                 Debug.Log("The ad was successfully shown.");
    27.                 // Add 100 bait
    28.                 BaitScore.Add(Bait);
    29.                 bsm.UpdatedHS();
    30.                 break;
    31.             case ShowResult.Skipped:
    32.                 Debug.Log("The ad was skipped before reaching the end.");
    33.                 break;
    34.             case ShowResult.Failed:
    35.                 Debug.LogError("The ad failed to be shown.");
    36.                 break;
    37.         }
    38.     }
    39. }

    I can't find any errors in the full build log but it does say "4547: [Unity] Player export failed. Reason: 2 errors", I have no idea what's going on.


    EDIT: Ok guys, my problem was fixed the same as kazuki_kyakuno, update to path 5.5.0p3

    Thanks,
    Brian
     
    Last edited: Jan 7, 2017
  2. UsernameZero

    UsernameZero

    Joined:
    Feb 19, 2015
    Posts:
    29
    Bump, still needing help with this...
     
  3. SophiaC

    SophiaC

    Unity Technologies

    Joined:
    Sep 6, 2016
    Posts:
    238
  4. kazuki_kyakuno

    kazuki_kyakuno

    Joined:
    Feb 9, 2015
    Posts:
    7
    I have the same problem. This is my log.
    iOS build works fine. But Android build with Unity Ads doesn't work.

     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,775
    Try the latest Unity 5.5 patch release, 5.5.0p3. We had a bug with the Android/IL2CPP Ads integration that was corrected in this version. I'm not entirely sure you are seeing the same issue, the 5.5.0f3 definitely won't work. If 5.5.0p3 still does not work, please let us know, and we'll try to track down the cause of the problem.
     
  6. kazuki_kyakuno

    kazuki_kyakuno

    Joined:
    Feb 9, 2015
    Posts:
    7
    My problem was resolved at 5.5.0p3. Thanks.
     
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,775
    Great, I'm glad to hear that!
     
  8. UsernameZero

    UsernameZero

    Joined:
    Feb 19, 2015
    Posts:
    29
    This has also fixed my problem, I didn't even notice this patch existed but after changing my target to use 5.5.0p3 it built and works fine on my device. :) Thanks Josh, much love! <3
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,775
    I'm glad to hear that your issue is corrected!