Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Invalid JSON string error immediately after ads are initilialized

Discussion in 'Unity Ads' started by MadsirStudio, Mar 18, 2020.

  1. MadsirStudio


    Feb 15, 2020
    A few days ago I used the Services window to turn on ads and linked the project to my unity developer account. I tested it in editor and on an Android device and everything worked fine with the test ads. Since yesterday, every time I push play in editor I get this error:

    UnityAdsEditor: Initialize([redacted], True);

    SerializationException: Invalid JSON string
    SimpleJson.SimpleJson.DeserializeObject (System.String json) (at C:/buildslave/unity/build/Runtime/Web/Managed/SimpleJson.cs:544)
    UnityEngine.Advertisements.UnityAdsEditor.HandleResponse (UnityEngine.WWW www) (at C:/buildslave/unity/build/Extensions/UnityAds/UnityAds/UnityAdsEditor.cs:48)
    UnityEngine.Advertisements.UnityAdsEditor+<GetAdPlan>c__Iterator0.MoveNext () (at C:/buildslave/unity/build/Extensions/UnityAds/UnityAds/UnityAdsEditor.cs:36)
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

    I've spent hours trying to find a solution to this and I'm stuck. Can someone please help?
  2. SamOYUnity3D


    Unity Technologies

    May 12, 2019
    What version of Unity Ads SDK are you using? You can see the version using:
    Code (CSharp):
    1. Debug.Log("Ads SDK version:" + Advertisement.version);
    If you are using the 1.x version, please upgrade to the latest version. The 1.x version is no longer recommended.
  3. MadsirStudio


    Feb 15, 2020
    Thanks for responding! When I use that log it says:

    Assets/Scripts/RewardedAdsButton.cs(12,54): error CS0117: `UnityEngine.Advertisements.Advertisement' does not contain a definition for `version'

    The engine recognizes UnityEngine.Advertisements as a namespace. I used the example code provided by Unity and none of the functions throw an error but even when I remove the script from the project I still get the invalid JSON string error.

    Edit: I went through the files and it's version 1x. I'm using Unity 5.3.8p2. If I disable ads in the service window and then import the Unity Ads SDK v 3.0 I get errors that Advertisements is defined multiple times.

    Edit2: After spending days trying to fix this and getting nowhere, I decided to backup my projects and update to Unity version 2018.4.19f1. Now everything is working fine.
    Last edited: Mar 19, 2020
    SamOYUnity3D likes this.