Search Unity

Problem with unity ads

Discussion in 'Unity Ads & User Acquisition' started by radin_game_studio, Feb 12, 2020.

  1. radin_game_studio

    radin_game_studio

    Joined:
    Nov 3, 2019
    Posts:
    2
    Hi. our game has been published in google play. We have used unity ads. In editor, everything is right and we see the banner (This screen would be your ad unit, everything seems to be working)
    We have checked game id and placement id. It is enabled and not on test mode.
    You can see the log below.
    Thank you in advance

    Code (CSharp):
    1.  if (!Advertisement.isInitialized)
    2.         {
    3. #if UNITY_ANDROID
    4.             Advertisement.Initialize("...");
    5. #elif UNITY_IOS
    6.             Advertisement.Initialize("...");
    7. #endif
    8.         }
    Code (CSharp):
    1.  public void ShowRewardedAd()
    2.     {
    3.         if (Advertisement.IsReady("rewardedVideo"))
    4.         {
    5.             var options = new ShowOptions {resultCallback = HandleShowResult};
    6.             Advertisement.Show("rewardedVideo", options);
    7.         }
    8.         else
    9.             ShowMessage.ins.ShowAlert(Messages.Title.Error, Messages.NoVideoAvailable, "OK");
    10.     }
    Code (CSharp):
    1. 02-12 11:54:59.380 D/UnityAds( 5477): com.unity3d.ads.cache.CacheDirectory.getCacheDirectory() (line:42) :: Unity Ads is using external cache directory: /storage/emulated/0/Android/data/com.Radin.TurboLegends/cache/UnityAdsCache
    2. 02-12 11:54:59.383 D/UnityAds( 5477): com.unity3d.ads.misc.Utilities.writeFile() (line:105) :: Wrote file: /storage/emulated/0/Android/data/com.Radin.TurboLegends/cache/UnityAdsCache/UnityAdsStorage-public-data.json
    3. 02-12 11:54:59.383 D/UnityAds( 5477): com.unity3d.ads.device.Storage.sendEvent() (line:82) :: Couldn't send storage event to WebApp
    4. 02-12 11:54:59.385 D/UnityAds( 5477): com.unity3d.ads.misc.Utilities.writeFile() (line:105) :: Wrote file: /storage/emulated/0/Android/data/com.Radin.TurboLegends/cache/UnityAdsCache/UnityAdsStorage-public-data.json
    5. 02-12 11:54:59.385 D/UnityAds( 5477): com.unity3d.ads.device.Storage.sendEvent() (line:82) :: Couldn't send storage event to WebApp
    6. 02-12 11:54:59.385 D/UnityAds( 5477): com.unity3d.ads.UnityAds.initialize() (line:109) :: ENTERED METHOD
    7. 02-12 11:54:59.386 I/UnityAds( 5477): com.unity3d.ads.UnityAds.initialize() (line:148) :: Initializing Unity Ads 2.1.1 (2101) with game id ... in production mode
    8. 02-12 11:54:59.388 I/UnityAds( 5477): com.unity3d.ads.UnityAds.initialize() (line:160) :: Unity Ads environment check OK
    9. 02-12 11:54:59.488 I/UnityAds( 5477): com.unity3d.ads.configuration.InitializeThread$InitializeStateConfig.execute() (line:214) :: Unity Ads init: load configuration from https://config.unityads.unity3d.com/webview/2.1.1/release/config.json
    10. 02-12 11:55:00.054 I/UnityAds( 5477): com.unity3d.ads.configuration.InitializeThread$InitializeStateLoadCache.execute() (line:267) :: Unity Ads init: webapp loaded from local cache
    11. 02-12 11:55:01.052 I/UnityAds( 5477): com.unity3d.ads.api.Sdk.logInfo() (line:70) :: Requesting configuration from https://publisher-config.unityads.unity3d.com/games/.../configuration?bundleId=com.Radin.TurboLegends&encrypted=true&rooted=false&platform=android&sdkVersion=2101&osVersion=9&deviceModel=Redmi%20Note%208&language=en_US&connectionType=wifi&screenHeight=1080&screenWidth=2130&test=false&deviceMake=Xiaomi&screenDensity=440&screenSize=268435810&advertisingTrackingId=64b0291b-1883-44c1-a442-ba0fbbe2f1d7&limitAdTracking=false&frameworkName=Unity&frameworkVersion=2018.4.8f1&adapterName=Engine&adapterVersion=2.1.1
    12. 02-12 11:55:01.539 E/UnityAds( 5477): com.unity3d.ads.api.Sdk.logError() (line:58) :: Initialization error: Unexpected token < in JSON at position 0
    13. 02-12 11:56:00.056 E/UnityAds( 5477): com.unity3d.ads.configuration.InitializeThread$InitializeStateCreate.execute() (line:367) :: Unity Ads WebApp creation failed!
    14. 02-12 11:56:00.057 E/UnityAds( 5477): com.unity3d.ads.configuration.InitializeThread$InitializeStateError.execute() (line:391) :: Unity Ads init: halting init in create webapp: Creation of WebApp failed!
    15. 02-12 12:10:58.489 D/UnityAds( 6166): com.unity3d.ads.cache.CacheDirectory.getCacheDirectory() (line:42) :: Unity Ads is using external cache directory: /storage/emulated/0/Android/data/com.Radin.TurboLegends/cache/UnityAdsCache
    16. 02-12 12:10:58.501 D/UnityAds( 6166): com.unity3d.ads.misc.Utilities.writeFile() (line:105) :: Wrote file: /storage/emulated/0/Android/data/com.Radin.TurboLegends/cache/UnityAdsCache/UnityAdsStorage-public-data.json
    17. 02-12 12:10:58.501 D/UnityAds( 6166): com.unity3d.ads.device.Storage.sendEvent() (line:82) :: Couldn't send storage event to WebApp
    18. 02-12 12:10:58.503 D/UnityAds( 6166): com.unity3d.ads.misc.Utilities.writeFile() (line:105) :: Wrote file: /storage/emulated/0/Android/data/com.Radin.TurboLegends/cache/UnityAdsCache/UnityAdsStorage-public-data.json
    19. 02-12 12:10:58.503 D/UnityAds( 6166): com.unity3d.ads.device.Storage.sendEvent() (line:82) :: Couldn't send storage event to WebApp
    20. 02-12 12:10:58.503 D/UnityAds( 6166): com.unity3d.ads.UnityAds.initialize() (line:109) :: ENTERED METHOD
    21. 02-12 12:10:58.504 I/UnityAds( 6166): com.unity3d.ads.UnityAds.initialize() (line:148) :: Initializing Unity Ads 2.1.1 (2101) with game id ... in production mode
    22. 02-12 12:10:58.521 I/UnityAds( 6166): com.unity3d.ads.UnityAds.initialize() (line:160) :: Unity Ads environment check OK
    23. 02-12 12:10:58.959 I/UnityAds( 6166): com.unity3d.ads.configuration.InitializeThread$InitializeStateConfig.execute() (line:214) :: Unity Ads init: load configuration from https://config.unityads.unity3d.com/webview/2.1.1/release/config.json
    24. 02-12 12:11:01.730 I/UnityAds( 6166): com.unity3d.ads.configuration.InitializeThread$InitializeStateLoadCache.execute() (line:267) :: Unity Ads init: webapp loaded from local cache
    25. 02-12 12:11:02.301 I/UnityAds( 6166): com.unity3d.ads.api.Sdk.logInfo() (line:70) :: Requesting configuration from https://publisher-config.unityads.unity3d.com/games/.../configuration?bundleId=com.Radin.TurboLegends&encrypted=true&rooted=false&platform=android&sdkVersion=2101&osVersion=9&deviceModel=Redmi%20Note%208&language=en_US&connectionType=wifi&screenHeight=1080&screenWidth=2130&test=false&deviceMake=Xiaomi&screenDensity=440&screenSize=268435810&advertisingTrackingId=64b0291b-1883-44c1-a442-ba0fbbe2f1d7&limitAdTracking=false&frameworkName=Unity&frameworkVersion=2018.4.8f1&adapterName=Engine&adapterVersion=2.1.1
     
    Last edited: Feb 12, 2020
  2. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Your code looks correct. And thanks for including the device log. Error seems to be "error: Unexpected token < in JSON at position 0", which sounds like SDK for some reason is unable to parse result from server (although don't really get why that would be case)

    Can you update your SDK version to latest? Will in any case make it easier for us to troubleshoot/debug the issue, if it's still present in latest SDK version.

    Thanks,
    Rasmus
     
  3. radin_game_studio

    radin_game_studio

    Joined:
    Nov 3, 2019
    Posts:
    2
    Now it is OK thanks!
    It was weird
     
    kyle-unity likes this.
  4. janiche

    janiche

    Joined:
    Jan 4, 2015
    Posts:
    52
    I have a similar error initializing my unity ADS integration. I'm using the last version of unity ads monetization 3.4.4 from PACKAGE MANAGER
    The initialization script is like: (android and ios id are assigned by inspector)

    Code (CSharp):
    1.  
    2.  
    3. #if UNITY_ANDROID
    4.         appKey = androidId;
    5. #elif UNITY_IOS
    6.         appKey = iosId;
    7. #elif UNITY_EDITOR
    8.         appKey = "1111111";
    9. #endif
    10.  
    11.         if (!Advertisement.isInitialized)
    12.         {
    13.             if (Advertisement.isSupported)
    14.             {
    15.                 //Advertisement.AddListener(this);
    16.                 Advertisement.Initialize(appKey, testMode);
    17.             }
    18.         }
    19.  
    20.         Advertisement.AddListener(this);
    21.     }
    Code (CSharp):
    1.     public void _ShowRewarded()
    2.     {
    3.         if (Advertisement.IsReady(_videoPlacement))
    4.         {
    5.             Advertisement.Show(_videoPlacement);
    6.         }
    7.  
    8.         //mostrar mensaje ad no disponible
    9.         else
    10.         {
    11.  
    12.         }
    13.     }
    Code (CSharp):
    1. 2020-03-18 19:25:50.888 28472-28499/com.Bermost.TheGurons D/Unity: System memory in use before: 58.1 MB.
    2. 2020-03-18 19:25:50.935 28472-28499/com.Bermost.TheGurons D/Unity: System memory in use after: 58.4 MB.
    3. 2020-03-18 19:25:50.935 28472-28499/com.Bermost.TheGurons D/Unity: Unloading 26 unused Assets to reduce memory usage. Loaded Objects now: 5099.
    4. 2020-03-18 19:25:50.935 28472-28499/com.Bermost.TheGurons D/Unity: Total: 46.235838 ms (FindLiveObjects: 2.320937 ms CreateObjectMapping: 0.948385 ms MarkObjects: 42.635316 ms  DeleteObjects: 0.327500 ms)
    5. 2020-03-18 19:25:50.935 28472-28545/com.Bermost.TheGurons D/Unity: Unloading 0 Unused Serialized files (Serialized files now loaded: 0)
    6. 2020-03-18 19:25:50.938 28472-28499/com.Bermost.TheGurons D/Unity: System memory in use before: 58.1 MB.
    7. 2020-03-18 19:25:50.982 28472-28499/com.Bermost.TheGurons D/Unity: System memory in use after: 58.3 MB.
    8. 2020-03-18 19:25:50.982 28472-28499/com.Bermost.TheGurons D/Unity: Unloading 0 unused Assets to reduce memory usage. Loaded Objects now: 5099.
    9. 2020-03-18 19:25:50.982 28472-28499/com.Bermost.TheGurons D/Unity: Total: 44.297036 ms (FindLiveObjects: 2.150730 ms CreateObjectMapping: 0.888854 ms MarkObjects: 41.169379 ms  DeleteObjects: 0.084792 ms)
    10. 2020-03-18 19:26:24.883 28472-28556/com.Bermost.TheGurons E/UnityAds: com.unity3d.services.core.configuration.InitializeThread$InitializeStateCreate.execute() (line:344) :: Unity Ads WebApp creation failed!
    11. 2020-03-18 19:26:24.884 28472-28556/com.Bermost.TheGurons E/UnityAds: com.unity3d.services.core.configuration.InitializeThread$InitializeStateError.execute() (line:383) :: Unity Ads init: halting init in create webapp: Creation of WebApp failed!
    12.