Failed resolution of: Lcom/google/android/gms/ads/InterstitialAd;

4,019 views
Skip to first unread message

BlueScreen

unread,
Apr 6, 2021, 9:08:50 PM4/6/21
to Google Mobile Ads SDK Developers
I am using Unity version 2019.4.20f1 and am trying to build my project onto an Android phone but the app keeps crashing when I try to create an ad with the following error that occurs on the device:

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/InterstitialAd;

at com.google.unity.ads.Interstitial$1.run(Interstitial.java:69)

I have tried Force Resolve in Unity and this does not fix the issue, as well as deleting and reimporting all of the third party packages. Does anybody know where I should start looking to fix the issue? I am not very familiar at all with Android so I am not sure where to even look.

Mobile Ads SDK Forum Advisor Prod

unread,
Apr 6, 2021, 10:36:32 PM4/6/21
to google-adm...@googlegroups.com

Hi there,

Thank you for reaching out to us.

Were you able to replicate this issue in our sample apps using our unity package? If yes, can you share the steps on how to replicate it for us to investigate this further in our end.  

Also, could you please provide the following details via Reply privately to author option or send it directly to mobileads...@gmail.com?

  • Copy of a sample project (replicating the issue)
  • Full stack trace of the crash

Regards,

Google Logo
Princess Pamela Pineda
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2EqS0e:ref

naveen DayDreamzstudio

unread,
Apr 8, 2021, 8:27:23 AM4/8/21
to Google Mobile Ads SDK Developers
Hi there, 
Even im facing the same issue , you can replicate 
import the googlemobileads(mediation) plugin in unity and also the adnetwork plugins of unity ads, ironsource ads, applovin ads, facebook ads.

and when build and run it on the device with internet , im facing this error. 

Mobile Ads SDK Forum Advisor Prod

unread,
Apr 8, 2021, 2:45:02 PM4/8/21
to naveen.dayd...@gmail.com, google-adm...@googlegroups.com
Hi there,

Thank you for bringing some replication steps to get this crash to our attention. Could you give us the version numbers for all the adaptors and other plugins to make this crash happen?

Regards,

Google Logo
Aryeh Baker
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2EqS0e:ref

BlueScreen

unread,
Apr 8, 2021, 3:34:25 PM4/8/21
to Google Mobile Ads SDK Developers
Here are the complete steps to replicate, you only need to add the Facebook Mediation adapter for the crash to occur:
  1. Create a Unity project using the Google Admob Samples project: Go to Unity Hub > Add Project > select the Hello World folder from the Google Admob Samples project link you provided.
  2. Open the newly created project using Using Unity Version 2019.4.20f1
  3. Import Google Mobile Ads SDK v5.4.0, Agree / Apply to all dialogs that appear.
  4. Menu > Assets > Google Mobile Ads > Settings > enable Google AdMob and enter in the sample ID for Android: ca-app-pub-3940256099942544~3347511713
  5. Build and Run onto Device. The Build will fail with the error "Failed to update Android SDK package list. See the Console for details." Fix the build errors like this:
    • Preferences > External Tools > uncheck the 4 Android paths to build tools (JDK, Android SDK, Android NDK, and Gradle)
    • Build And Run onto Device. The Build will fail again.
    • Preferences > External Tools > recheck the 4 Android paths to build tools that were unchecked before.
  6. Build And Run onto Device.
  7. The App will run on the device > Tap Request Interstitial Ad, then show Interstitial Ad > an interstitial appears so the result is ok.
  8. Return to Unity, import Facebook mediation adapter version 3.2.0
  9. Build And Run onto Device. The Build will fail while Building Gradle Project with the error "Build Failure > Android resource linking failed See the Console for details". Fix the build errors like this:
    • Player Settings > Publishing Settings > Enable Custom Base Gradle Template
    • Edit the custom Base Gradle Template that gets created in the Plugins > Android folder to update the dependency from 3.4.0 to 3.4.3:
      • classpath 'com.android.tools.build:gradle:3.4.3'
  10. Build and Run onto Device
  11. App is running on device > Tap Request Interstitial Ad > app crashes.
I will send you the complete project and stack trace to the email you provided.

BlueScreen

unread,
Apr 8, 2021, 4:21:28 PM4/8/21
to Google Mobile Ads SDK Developers
Project and stack trace sent. Please let me know if you are able to reproduce the error.

Thanks.

Mobile Ads SDK Forum Advisor Prod

unread,
Apr 8, 2021, 4:53:03 PM4/8/21
to google-adm...@googlegroups.com

Hi there,

 

Thank you for the full detailed replication steps. My way of adding the sample app is a little bit different from yours so I will state how I got the Facebook adapter to work with Interstitial loading, showing and destroying without crashing.

  1. Create A Unity project from scratch.
  2. Drag the folder for the HelloWorld project into assets and make the scene the current scene.
  3. Change the AdMobController.cs to initialize like the mediation guide shows.
  4. Follow the Main Guide to start an AdMob integration until where initialization is discussed.
  5. Set build to Android and run without problems.
  6. Return to Unity, import Facebook mediation adapter version 3.2.0.
  1. Build And Run onto Device. The Build will fail while Building Gradle Project with the error "Build Failure > Android resource linking failed See the Console for details". Fix the build errors like this:
    • Player Settings > Publishing Settings > Enable Custom Base Gradle Template and Custom Gradle Properties template.
    • Make sure that jetifier is set to true - "android.enableJetifier=true" in gradleTemplate.properties.
    • Edit the custom Base Gradle Template that gets created in the Plugins > Android folder to update the dependency from 3.4.0 to 3.4.3: - "classpath 'com.android.tools.build:gradle:3.4.3". I also enabled custom Main Gradle Template but didn't test if necessary.

    Run without issues. Please respond if this doesn't fix the issue.

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 8, 2021, 5:01:02 PM4/8/21
    to google-adm...@googlegroups.com
    Hi there,

    I tried to locate your project in mobileads...@gmail.com and didn't succeed. If following the steps I outlined you still have an issue, could you send the project again?

    BlueScreen

    unread,
    Apr 8, 2021, 5:56:24 PM4/8/21
    to Google Mobile Ads SDK Developers
    Ok, I don't think that the way that we are creating the project is going to make a difference, so I just looked to see what we might be doing different after step 6 in your instructions.

    First, in my project, I tried enabling Custom Grade Properties Template, and that did not fix the issue. Then I tried enabling Custom Main Gradle Template, and that does fix the issue. To be sure which change fixed the issue, I went back and disabled Custom Gradle Properties Template while keeping Custom Main Gradle Template enabled, and the issue is fixed. So apparently, enable Custom Main Gradle Template is the change needed to fix the issue.

    I would still like confirmation that you are able to replicate the issue on your end by disabling Custom Main Gradle Template. If this does not work in your project for some reason, please check your gmail again - I resent my project.

    In any case, if this is what we are supposed to do - the SDK implementation instructions need to be updated to reflect this. It looks like there are a couple of steps that we are having to do manually that are not provided in the instructions (i.e. update the Gradle dependency and enable Custom Main Gradle Template).

    Thanks.

    BlueScreen

    unread,
    Apr 8, 2021, 8:44:10 PM4/8/21
    to Google Mobile Ads SDK Developers
    I was able to get it working on my original project as well, but on that project I did have to enable both:

    Custom Main Gradle Template
    as well as
    Custom Gradle Properties Template

    The project would not build unless I enabled Custom Gradle Properties Template. The specific Console error I got without enabled Custom Gradle Properties Template was this:

    Resolution Failed.

    Resolution failed because EDM4U could not enable Jetifier in Unity 2019.4 without Custom Gradle Properties Template. Please enable 'Custom Gradle Properties Template' found under 'Player Settings > Settings for Android -> Publishing Settings' menu. Due to changes in Gradle project generated by Unity 2019.3 and above, our recommended way of enabling Jetifier is by injecting properties to Assets/Plugins/Android/gradleTemplate.properties.
    If you like to patch this yourself, simply disable 'Patch gradleTemplate.properties' in Android Resolver settings.

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 9, 2021, 9:30:36 AM4/9/21
    to google-adm...@googlegroups.com
    Hi there,

    Thank you for getting back to me with your findings. From your experiences it appears that every specific project with each difference in setup can have differing build requirements. This is one of the reasons why it's impracticable to publish specific requirements for each unitypackage update, especially if you add in all the variations in Unity version, AdMob version, mediation versions and other packages, each variation potentially creating other issues.

    Another solution would be to upgrade to a newer Unity version.

    You are requesting something that would be helpful for publishers and there may be sensible publishing of specifications. To start the conversation, would publishing in each adapter changelog the gradle version required and all dependencies published by the SDK vendor be helpful? Please let me know your thoughts so that I can share this with my team.

    BlueScreen

    unread,
    Apr 9, 2021, 7:29:01 PM4/9/21
    to Google Mobile Ads SDK Developers
    First of all, thank you for pointing me in the right direction in how to solve the problem - now this is working again for me! Great!

    Second of all, I understand that there could be lots of iterations and combinations that could cause problems.

    However, in this case, we are talking about a single adapter, the Facebook Mediation Adapter. I tried getting it to work on an updated version of Unity (the current recommended version which is Unity 2020.3.3f1 LTS) and it still does not work!

    So as far as solutions, my recommendation for your team, is that for each update of an adapter or AdMob itself, to test the creation of a new project on the latest Unity version for each release version or year that you are supporting (so for example, the latest LTS version of Unity 2019, 2020, and the most recent current version of 2021), and to try adding each adapter to see if you can run it successfully on a device without errors. You should do this for each adapter individually, and then do this for all of the adapters at once (since it is possible that someone would install all of the adapters).

    I know that this seems like a lot of work, but as it stands, the instructions posted currently simply do not work for the latest recommended version of Unity. It is only possible to get it to work with the additional steps that we have outlined here - which could be very difficult for a developer to track down on their own.


    Maybe it worked at one time, and it is only a recent version of the facebook adapter which is causing the issue. Which is my point. It would greatly help if your team could check the integration for each new release, as part of your testing. It has me about a week to troubleshoot this issue and this is a lot of lost time!

    Thank you

    naveen DayDreamzstudio

    unread,
    Apr 12, 2021, 1:44:37 AM4/12/21
    to Google Mobile Ads SDK Developers
    Hello,  For me the version im using is  Google Mobile Ads SDK v5.4.0, FB Adnetwork Version 3.2.0 and unity 2021.1. Only crashes when importing FB Adnetwork into the project.  

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 12, 2021, 2:06:22 AM4/12/21
    to google-adm...@googlegroups.com

    Hi there,

    Thank you for reaching out to us.

    I'm working with Aryeh and will be assisting you today. With regard to your recommendation, as my colleague mentioned that it's impracticable to publish specific requirements for each unity package update and it seems that it happens on case to case basis. With that, we still want to thank you for your recommendation for the team.

    Regards,

    Google Logo
    Princess Pamela Pineda
    Mobile Ads SDK Team
     

     

    ref:_00D1U1174p._5004Q2EqS0e:ref

    DayDreamzstudio_N

    unread,
    Apr 12, 2021, 2:55:19 AM4/12/21
    to Google Mobile Ads SDK Developers
    Hello, 
    Could please help me out from this issue. 

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 12, 2021, 3:06:18 AM4/12/21
    to naveen.dayd...@gmail.com, google-adm...@googlegroups.com

    Hi there,

    Thank you for reaching out to us.

    Were you able to upgrade to newer Unity version and still encountered crashes when importing FB AdNetwork into your project? Also, are you able to try what my colleague steps in adding the sample app and got the Facebook adapter to work with Interstitial loading, showing and destroying without crashing?

    Regards,

    Google Logo
    Princess Pamela Pineda
    Mobile Ads SDK Team
     


    ref:_00D1U1174p._5004Q2EqS0e:ref

    DayDreamzstudio_N

    unread,
    Apr 12, 2021, 3:32:06 AM4/12/21
    to Google Mobile Ads SDK Developers
    im using latest unity version which 2020.1, ill give it a try with following the steps and let you know.

    DayDreamzstudio_N

    unread,
    Apr 12, 2021, 7:28:17 AM4/12/21
    to Google Mobile Ads SDK Developers
    We followed the steps mentioned. There was no build error but the app is still crashing while requesting the interstitialAd

    Alex Anh

    unread,
    Apr 12, 2021, 8:55:46 AM4/12/21
    to Google Mobile Ads SDK Developers
    Same, I updated Unity 2019.4.23 not error but crash.

    Vào lúc 18:28:17 UTC+7 ngày Thứ Hai, 12 tháng 4, 2021, DayDreamzstudio_N đã viết:

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 12, 2021, 11:17:02 AM4/12/21
    to naveen.dayd...@gmail.com, google-adm...@googlegroups.com
    Hi there,

    I tested on Unity 2020.1.0 and with these steps just not changing the already updated Android Gradle plugin the issue showed itself. When I did a resolve plus doing a force resolve then it worked. I didn't test yet with just resolve or force resolve. This is with Facebook, Applovin, Unity Ads and IronSource adapters and SDK's installed. I also had to delete the temp folder to get around a dependency issue.

    Regards,

    Google Logo
    Aryeh Baker
    Mobile Ads SDK Team
     


    ref:_00D1U1174p._5004Q2EqS0e:ref

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 12, 2021, 12:02:21 PM4/12/21
    to qagl...@gmail.com, google-adm...@googlegroups.com
    Hi Alex,

    I tested on Unity 2019.4.23 with the latest facebook adapter following the steps described in this thread and the interstitials loaded without problems.

    Regards,

    Google Logo
    Aryeh Baker
    Mobile Ads SDK Team
     


    ref:_00D1U1174p._5004Q2EqS0e:ref
    Message has been deleted

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 13, 2021, 1:37:09 AM4/13/21
    to qagl...@gmail.com, google-adm...@googlegroups.com

    Hi Alex,

    Thank you for your response.

    I work with Aryeh and will be assisting you today. Could you please create a new thread regarding this issue for us to track it better and for other user to use the thread when they face the same problem. Also, for us to investigate further the crashes happened using GoogleMobileAds-native.unitypackage package, could you please provide the following details via Reply privately to author option or send it directly to mobileads...@gmail.com?

    • Crash log
    • Steps to replicate the crash
    • Unity Version
    • Adaptors/Plugin used

    Regards,

    Google Logo
    Princess Pamela Pineda
    Mobile Ads SDK Team
     


    ref:_00D1U1174p._5004Q2EqS0e:ref

    DayDreamzstudio_N

    unread,
    Apr 13, 2021, 2:17:51 AM4/13/21
    to Google Mobile Ads SDK Developers
    Hello, we have created a new thread about the crash please look in to it. 

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 13, 2021, 5:14:30 AM4/13/21
    to naveen.dayd...@gmail.com, google-adm...@googlegroups.com

    Hi there,

    Thank you for your response.

    I could see that you've created a new thread with the same error logs presented on this existing thread. Have you tried the solution steps that my colleague made? If so, please let me know if the issue still persists.

    Alex Anh

    unread,
    Apr 13, 2021, 6:03:38 AM4/13/21
    to Google Mobile Ads SDK Developers
    Hi Support team,
    I send you project crash


    - Open Unity 2019.4.24 (Android build)
    - Build and run in device (no more action from you)
    - Crash when click on Request Intertial ads.

    Information from project
    - Project Helloworld example
    - GoogleMobileAds-v5.4.0.unitypackage
    - GoogleMobileAdsFacebookMediation-3.2.0

    Thank for your support


    Vào lúc 16:14:30 UTC+7 ngày Thứ Ba, 13 tháng 4, 2021, mobileadssdkforumadvisor đã viết:
    Message has been deleted

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 13, 2021, 9:53:26 AM4/13/21
    to qagl...@gmail.com, google-adm...@googlegroups.com
    Hi Alex,

    Thank you for sending us your project. When following your instructions I was able to replicate the crash on loading the Interstitial, and the crash was the same as what everyone on this thread was encountering. 

    When I added the Custom Gradle Properties Template and the Custom Main Gradle Template to the player and forced resolve the Interstitial loaded without problem. 

    Regarding the GoogleMobileAds-native.unitypackage, this package is incompatible with Facebook adapter, as Native ads aren't supported in mediation with Facebook. According to our Native Ad Prerequisites you have to uninstall the regular Mobile Ads Unitypackage before installing the Native Ads Unitypackage.

    Regards,

    Google Logo
    Aryeh Baker
    Mobile Ads SDK Team
     
     

    ref:_00D1U1174p._5004Q2EqS0e:ref
    Reply all
    Reply to author
    Forward
    0 new messages