Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice
  2. We've opened up a space to discuss, share feedback, and showcase everything related to the Unity Shader Graph! Come show us what you've made.
    Dismiss Notice

Unity Ads are just working in editor

Discussion in 'Unity Ads' started by Matanyos, Feb 7, 2019.

  1. Matanyos

    Matanyos

    Joined:
    Nov 4, 2016
    Posts:
    7
    hey guys
    first, the Unity Monetization sdk ASSET does not allow me to build apk because it has problem of duplicated files when i merging DEX files.(i had to remove the imported plugins to elimante the duplicate files),just kept the unity ads folder imported from the asset.

    second, after initializing equal True and is ready equal True, everything works fine in editor, BUT the ads are not showing on moblie!

    i Need a Solution



    this is my code


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Advertisements;

    public class UnityAds : MonoBehaviour
    {
    private float lasttime;
    public GameObject player;
    private string androidID = "3032128";
    private string iosID = "3032129";
    void Start()
    {
    Advertisement.Initialize(androidID,true);
    Debug.Log(Advertisement.isInitialized);
    }
    public void ShowRewarded()
    {
    ShowOptions options = new ShowOptions { resultCallback = HandleShowResult };
    if (Advertisement.IsReady())
    Debug.Log("ready");
    Advertisement.Show("rewardedVideo", options);
    }
    public void ShowIn()
    {
    if(Time.time > lasttime + 10)
    {
    if (Advertisement.IsReady())
    Debug.Log("ready");
    Advertisement.Show("video");
    lasttime = Time.time;
    }
    }
    void HandleShowResult(ShowResult result)
    {
    if (result == ShowResult.Finished)
    {
    Time.timeScale = 1;
    player.GetComponent<Player>().ExtraLife();
    }
    else if (result == ShowResult.Skipped)
    {
    Debug.LogWarning("The player skipped the video - DO NOT REWARD!");
    }
    else if (result == ShowResult.Failed)
    {
    Debug.LogError("Video failed to show");
    }
    }
    }
     
  2. Matanyos

    Matanyos

    Joined:
    Nov 4, 2016
    Posts:
    7
    This is what i kept from the Unity Monetization ASSET
     

    Attached Files:

  3. DenisasK

    DenisasK

    Unity Technologies

    Joined:
    Oct 13, 2016
    Posts:
    87
    Hello @Matanyos
    In order to get rid of duplicated files when merging the DEX files, you need to remove the ads package from a PackagManager, also, turn off ads from a service window.
    About your init issue, please, can you attach the ADB logs, or fill out a bug report via BugReporter.