Search Unity

Can't upgrade Unity Ads to the latest version

Discussion in 'Unity Ads & User Acquisition' started by momcil0, Apr 2, 2019.

  1. momcil0

    momcil0

    Joined:
    May 23, 2016
    Posts:
    3
    I have a game which is live on App Store and Google Play. Video ads work on both apps. They were built on Mac with Unity
    2018.2.18
    . Now when I try to build for Android and iOS, ads don't work, and here is what I'm doing.
    1. I upgraded Unity to
      2018.2.21f1
      . I decided to keep Unity
      2018.2
      because most of my scripts are in UnityScript. I know that's legacy, but time is crucial now and besides Monetization 3.0.3 is supposed to be working with it.
    2. I open the backed-up project (the one that works on both stores). It is imported succesfully from 2018.2.18 version. In
      Packages/manifest.json
      it says
      "com.unity.ads": "2.0.8"
      , which is in fact the version that was used in the build.
    3. I Build&Run it for Android as is, deploy it on the device and the video ads don't show anymore. In Editor, everything seems to be working fine.
    4. When I open Services/Ads, I get the warning that I should update Unity Ads to the latest version or re-enable the internal Ads extension.
    5. I first try to re-enable the internal ads extension. Build fails with:
      Code (JavaScript):
      1. Execution failed for task ':transformDexWithDexForRelease'.
      2. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/unity3d/ads/BuildConfig;
    6. I then turn off built-in Ads Extension, and I get the same message in Services/Ads - to import the latest Unity Ads plugin from the asset store.
    7. I first try to update it via Package Manager, which shows that I have "Ads" package
      2.0.8.
      and offers the update to
      2.3.1
      . I update it and that seems to succeed as the name of the package changes to "Advertisement" and
      Packages/manifest.json
      now says
      "com.unity.ads": "2.3.1"
      , but I get the following error in the console:
      Code (JavaScript):
      1. error CS1704: An assembly with the same name `UnityEngine.Advertisements.Editor' has already been imported. Consider removing one of the references or sign the assembly
      2. Assets/UnityAds/UnityEngine.Advertisements.Editor.dll (Location of the symbol related to previous error)
      3. /Users/momcilo/Library/Unity/cache/packages/packages.unity.com/com.unity.ads@2.3.1/Runtime/UnityEngine.Advertisements.Editor.dll (Location of the symbol related to previous error)
    8. Following some advices I found on the internet, I did
      Assets/Reimport All
      to solve this issue. It didn't help and I still get the same error as in 7.
    9. I then went to Asset Store, found Monetization 3.0.3 and tried to import it. It apparently succeeded, but the errors remained the same, and
      Packages/manifest.json
      still states
      "com.unity.ads": "2.3.1"
      .
    10. Following advice from one of the forum posts, I wanted to delete the Advertisement package from Package Manager, but... Package Manager wasn't there anymore?! I gave up at this point.
    I am completely confused as to what to do from this point on. Ideally:
    • I would like to keep Unity
      2018.2.21f1
      because switching to C# now would be hell as I need to update the game quickly.
    • I understand that ads now require the latest API from Monetization 3.0.3, but I also see that Monetization 3.0.3 is supposed to support even Unity
      5.6.6
      .
    • I need to update the game without affecting the video ads functionality.
    How can I upgrade Unity Ads from the version I used in the apps that are on stores (
    "com.unity.ads": "2.0.8"

    ) to leverage the current API? As you can see, I have tried lots of different things, but none of it seems to work.
     
  2. DenisasK

    DenisasK

    Unity Technologies

    Joined:
    Oct 13, 2016
    Posts:
    89
    Hello @momcil0 ,
    I will skip some details and will try to provide the action points.
    First of all, remove the Monetization 3.0.3(Asset Store) package from your project, afterward, disable Ads from Service Window.
    At this point, you will have a lot of compiler errors inside a Console Window. Open inside your project folder Packages/manifest.json and delete com.unity.ads dependency. Reimport the project and import Monetization 3.0.3 from Asset Store again.
    Let me know if it will solve your issue.
     
  3. momcil0

    momcil0

    Joined:
    May 23, 2016
    Posts:
    3
    Hello @DenisasK
    Thanks you for being so quick to respond. I believe that it could have went the way you suggested to go around the problem, because I did something similar (prior to seeing your response) and I managed to solve the problem. Just for the sake of diligence, I will compile the whole solution here, and just mention that I based my actions on this post.
    1. I disabled Ads from Services
    2. I removed the Ads package from the Package Manager. This step removed com.unity.ads from the manifest.json as well.
    3. I just opened the contents of Monetization 3.0.3 and noted where it would place its files. Then I canceled import and first deleted manually all the files that were in places where Monetization 3.0.3 was about to place its files.
    4. I imported Monetization 3.0.3 from the Asset Store and there were no errors. The manifest.json file did not get updated, and I did not turn the Ads back on in Services - it seemed to work fine in Editor.
    5. In addition to that, I went through this article and made sure I replace all the instances of
      Advertisement.IsReady()
      with
      Monetization.IsReady()
      - that required adjusting other types and many other lines of code to solve ambiguities between what's in
      Monetization
      ,
      Advetisements
      and
      Purchasing
      .
    6. After the code worked in the Editor and I was able to successfully deploy it to an Android device, I turned the Ads back on in Services and turned off the built-in ads extension. It still worked and it appears it works now as well.
    Hope this helps.
     
  4. majacekic

    majacekic

    Joined:
    Jun 25, 2019
    Posts:
    1
    Disabling and enabling Ads form Service worked for me. Thank you.
     
  5. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    tried various googled options, none worked or gave rise to other issues. fixed it by upgrading unity, removing old ads version and my ads code. updating to 2019.3 with latest unity-ads from package manager, and fresh implementation. now works. :) but a pain to get there.
     
    kyle-unity likes this.