Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UnityAds not working on Android but works well in editor (yes -.- i know)

Discussion in 'Unity Ads & User Acquisition' started by impheris, Jan 29, 2019.

Thread Status:
Not open for further replies.
  1. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    Yes i know... Here is another one about this issue.
    I have SDK 3.0, i made the same script from de documentation with my id and placements, test mode and build-in ads extension is enable... i mean, it works in editor but no in android.

    I have two scripts below (of course game id here is: 1234567 for privacy reasons)

    And yes, platform in settings is Android
     

    Attached Files:

    ckaroun likes this.
  2. Zaine7673

    Zaine7673

    Joined:
    Feb 15, 2018
    Posts:
    238
    okay so I've tried your bannerads script on my project and it seems to work.

    the strange thing is, I've been trying to use the monetization sdk and it didnt work.

    try the settings that i have and it might work for you too.

    I've removed advertisements from package manager and installed the monetization sdk (3.0) I've also got my unity ads disabled in the services menu. These settings and your script seems to have worked and shows me a test ad on my android device.

    i hope that helps.

    UPDATE: btw i did not need the adint script at all
     
    ckaroun likes this.
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What is the runtime value of IsReady on your Android device? How are you debugging? You can either use Visual Studio and attach to the process on the device and debug, or simply monitor the logs and make generous use of Debug.Log statements (which will show in the logs) https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/
     
  4. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
    Hi, what are the reason to disable and remove this components related to unity Ads from the project?
     
  5. braedenk

    braedenk

    Joined:
    Nov 8, 2016
    Posts:
    7
    @FrASuing
    In recent versions of the Unity editor, the package manager has a version of Advertisements added by default. If you want to use Monetization 3.0 from the asset store, it will clash with what the Advertisements package that the package manager has; this is why you have to remove/disable the things mentioned by @Zaine7673
    I (and I think many others) have lost significant time before figuring that mess out; I hope the setup for Ads integration in the near future is much less confusing and clunky.
     
  6. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    Wow, Sorry for the delay brothers and thanks for your attention.

    i will try that, but for my, it seems to be complicated and i'm not a programmer.

    another think is, i have the admob plugin in the proyect because actually im using google ads but i want to change. I have all the scripts that show google ads in my game deativated but the folder is in the project (see image)
    Do i have to eliminate everithing from google ads?
     

    Attached Files:

  7. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    i also hoped that it would work, but its not working :(
     
  8. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    i'm very suprised that unity have this implementation so gray, i mean, it is easy to download some package and scripts, but its not working and i see this issue in other posts...
     
  9. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    ok, i did it, and i see some "Exceptions" related with "adlistener" and "monetization" (see the file)

    Update: new file with the game running in my phone
     

    Attached Files:

    • log.txt
      File size:
      16 KB
      Views:
      1,187
    Last edited: Feb 1, 2019
  10. Zaine7673

    Zaine7673

    Joined:
    Feb 15, 2018
    Posts:
    238
    This is a silly question but have you set up a placement in the ads dashboard with the banner placement id you are using on the script?

    I found that previously when i had a problem like this where it would display on the editor but not on the phone it was because there was a fault with my placement id. just something else to check.
     
  11. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    Its a silly question hahaha but its fine, and yes i have those placements in the dashboard also i copied the name with the button on the dashboard
     
  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You might not be a programmer, but you are programming! Debugging is critical skill to have, it advised to learn how!
     
    Beerfootbandit likes this.
  13. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    Hi, maybe you did not see it but i did what you say, and i uploaded the file...
    Here is again the same file
     

    Attached Files:

    • log.txt
      File size:
      16 KB
      Views:
      790
  14. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    So... nobody knows??? do i have to stay with google?
     
  15. reddy36996

    reddy36996

    Joined:
    Jan 10, 2016
    Posts:
    19
    Hi,
    I integrated Unity ads into my project. Already enabled Ads in Unity Services, and set the proper game id (from operate dashboard) while initializing Ads. But I'm getting IsReady value as false at runtime in android device, it works fine in editor though. I have also checked with both approach using Advertisement.Initialize and Monetization.Initialize, with former approach i'm not getting any logs while latter prints some logs in logcat. Also code used is from directly unity samples.
    But before Initialize is called, i think it is automatically initialized just after splash screen, there it throws some error:

    Code (CSharp):
    1.  
    2. 02-11 21:26:42.807  8885  8920 D UnityAds: com.unity3d.services.core.misc.Utilities.writeFile() (line:127) :: Wrote file: /data/user/0/com.teenpatti.game/files/UnityAdsStorage-public-data.json: com.teenpatti.game
    3. 02-11 21:26:42.807  8885  8920 D UnityAds: com.unity3d.services.core.device.Storage.sendEvent() (line:81) :: Couldn't send storage event to WebApp: com.teenpatti.game
    4. 02-11 21:26:42.820  8885  8920 D UnityAds: com.unity3d.services.core.misc.Utilities.writeFile() (line:127) :: Wrote file: /data/user/0/com.teenpatti.game/files/UnityAdsStorage-public-data.json: com.teenpatti.game
    5. 02-11 21:26:42.821  8885  8920 D UnityAds: com.unity3d.services.core.device.Storage.sendEvent() (line:81) :: Couldn't send storage event to WebApp: com.teenpatti.game
    6. 02-11 21:26:42.825  8885  8920 D UnityAds: com.unity3d.services.ads.UnityAdsImplementation.initialize() (line:45) :: ENTERED METHOD: com.teenpatti.game
    7. 02-11 21:26:42.826  8885  8920 D UnityAds: com.unity3d.services.UnityServices.initialize() (line:41) :: ENTERED METHOD: com.teenpatti.game
    8.  
    9. 02-11 21:26:42.826  8885  8920 E UnityAds: com.unity3d.services.UnityServices.initialize() (line:61) :: Error while initializing Unity Services: empty game ID, halting Unity Ads init: com.teenpatti.game
    10.  
    i have tested with both test mode set to On and Off. I checked UnityConnectSettings as well, game ids are proper there
     
  16. DenisasK

    DenisasK

    Unity Technologies

    Joined:
    Oct 13, 2016
    Posts:
    89
    Hello @reddy36996
    It looks like you are initializing with empty gameID. Error while initializing Unity Services: empty game ID, halting Unity Ads init.
    Please, turn off the ads from a service window. Use PackageManager integration or AssetStore package only. GameID must be initialized via code.
    Something like this:
    [SerializeField] string gameID = "123456789";

    void Awake()
    {
    Advertisement.Initialize (gameID, true); or Monetization.Initialize(gameID, true)
    }
     
  17. reddy36996

    reddy36996

    Joined:
    Jan 10, 2016
    Posts:
    19
    Hi @DenisasK
    Thanks for replying back. I removed PackageManager integration which i was using and integrated assetstore package. Now Ads are working properly. Though I wonder why packagemanager integration is taking empty game id.
     
  18. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,621
    yeah im glad that your problem is solved, but mine is not -.- (the reason for THIS POST)
     
  19. DenisasK

    DenisasK

    Unity Technologies

    Joined:
    Oct 13, 2016
    Posts:
    89
    I have seen a similar issue a very long time ago. Can you try to find the UnityConnectSettings.asset file(YourProjectName/ProjectSettings/UnityConnectSettings.asset file), make a backup copy of a file and delete original one. Keep in mind that Unity Editor must be closed. Let me know if it will solve your issue.
     
  20. FrASuing

    FrASuing

    Joined:
    Sep 8, 2017
    Posts:
    19
    However, unity always (in my case) erase the UnityConnectSettings.asset file (if I modify it) and bring up the
    'original one' with no values
    I try to follow this instructions. I did this when unity was closed.
    Do these values affect the ads?
     
  21. KEM4

    KEM4

    Joined:
    Nov 22, 2017
    Posts:
    8
    Whoever checks this topic. I can give you a tip. I faced the same issue. The issue for me was that I copied Apple game id and NOT the Android gameId from the settings for the project. Either you set up the if statement in the code or make sure you switch between both ids when you test on android or iOS device.
     
    eduardovmendes likes this.
Thread Status:
Not open for further replies.