[Google Mobile Ads Unity] - AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/Interstitialad;

4,478 views
Skip to first unread message

eraya...@gmail.com

unread,
Apr 25, 2021, 12:45:20 AM4/25/21
to Google Mobile Ads SDK Developers
  • Unity version: 2019.4.21f1
  • Google Mobile Ads Unity plugin version: 5.4.0 (last)
  • Platform: Android
  • Platform OS version: All
  • Mediation ad networks used, and their versions: Facebook Audience Network 3.2.0


I last updated my app on 03/03/21. I was using the same version of Unity Editor, Google Mobile Ads and Facebook Audience Network Adapter. There is no problem and works fine. But now, I did External Dependency Manager/Android Resolver/Force Resolver without changing anything in the project , It doesn't work anymore. Builds and the game runs smoothly. But it gives this error while creating the new interstitial ad.

"AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/Interstitialad;"

I later realized, Works fine with Play-Services-19.7.0 version But It doesn't work Play-Services-20.0.0 version and gives an error. Play Services Resolver automatically integrates Play-Services-20.0.0 version. I can't no longer roll back to Play-Services-19.7.0.

Google Mobile Ads Unity plugin needs to be updated urgently. It should compatible with Play-Services-20.0.0 version.


eraya...@gmail.com

unread,
Apr 25, 2021, 1:06:06 AM4/25/21
to Google Mobile Ads SDK Developers
Edit : I deleted the Facebook Audience Network Adapter and I did Force Resolve. Play Services Resolver automatically integrates Play-Services-19.5.0 version and it works smoothly. I added Facebook Audience Network Adapter and I did Force Resolve again. This time, Play Services Resolver automatically integrated Play-Services-20.0.0 version and doesn't work anymore.

25 Nisan 2021 Pazar tarihinde saat 07:45:20 UTC+3 itibarıyla eraya...@gmail.com şunları yazdı:

Mobile Ads SDK Forum Advisor Prod

unread,
Apr 26, 2021, 1:59:02 AM4/26/21
to eraya...@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 error into your project? Also, can you try these steps in adding the sample app and got the Facebook adapter to work with Interstitial loading, showing and destroying without crashing? Let me know how it goes.

Regards,

Google Logo
Princess Pamela Pineda
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2GHNQa:ref

eraya...@gmail.com

unread,
Apr 26, 2021, 3:14:13 AM4/26/21
to Google Mobile Ads SDK Developers
I've tried all the options but it's still the same. Also gives error on Rewarded Ad Request :

"AndroidJavaException: java.lang.InstantiationError: com.google.android.gms.ads.rewarded.RewardedAd"

Gives error in the following lines

admob.png


The problem is caused by Play Services Resolver automatically integrates Play-Services-20.0.0 aar version when Facebook adapter is added. Class names changed in Play-Services-20.0.0 version.  
Documentation : https://developers.google.com/admob/android/migration

So , Google Mobile Ads Unity needs to be compatible with version Play-Services-20.0.0.
26 Nisan 2021 Pazartesi tarihinde saat 08:59:02 UTC+3 itibarıyla mobileadssdkforumadvisor şunları yazdı:

Mobile Ads SDK Forum Advisor Prod

unread,
Apr 26, 2021, 4:48:07 AM4/26/21
to eraya...@gmail.com, google-adm...@googlegroups.com

Hi there,

Thank you for your response.

Could you please provide us the following details so that we can investigate this further? You can send it via Reply privately to author option or send it directly to mobileads...@gmail.com.

  • App ID
  • Ad unit ID/s affected
  • Sample project(if any)
  • Steps to replicate error
  • Stack traces

eraya...@gmail.com

unread,
Apr 26, 2021, 5:13:53 AM4/26/21
to Google Mobile Ads SDK Developers
App ID and Ad Unit ID are not needed because the issue is not related to these. I don't have a sample project.

Steps to replicate error :

  1. Import Google Mobile Ads Unity Plugin on your Unity Project
  2. Import Facebook Audience Network Adapter on your Unity Project
  3. MobileAds Initialize and Create Interstitial Ad Object or Rewarded Ad Object in the code
  4. Do Play Services Resolver / Force Resolver
  5. Build your Project for Android
  6. Install .APK on your Android Device
  7. Run
  8. And error appears when creating Insterstitial Ad Object or Rewarded Ad Object

26 Nisan 2021 Pazartesi tarihinde saat 11:48:07 UTC+3 itibarıyla mobileadssdkforumadvisor şunları yazdı:

Mobile Ads SDK Forum Advisor Prod

unread,
Apr 26, 2021, 11:42:34 AM4/26/21
to eraya...@gmail.com, google-adm...@googlegroups.com
Hi there,

I work with Pamela and will assist you. Using Unity version 2019.4.21f, our sample "Hello World" app, our Unitypackage 5.4.0 and Facebook Mediation 3.2.0, when I went to Player Settings -> Publishing Settings when in Android and selected the options for the following:
  1. Custom Main Gradle Template
  2. Custom Base Gradle Template
  3. Custom Gradle Properties Template
I then followed the directory to the Custom Base Gradle Template and specified the custom Gradle version like this:
 classpath 'com.android.tools.build:gradle:3.4.3'

​​​​​​​After saving and force resolving the sample app ran fine. 

Every other permutation of versions of Unity, mediation packages and our SDK may have other build problems. The simplest way to resolve these issues is to have a later Unity version.

Feel free to get back to us if this doesn't help for your use case.

Regards,

Google Logo
Aryeh Baker
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2GHNQa:ref

eraya...@gmail.com

unread,
Apr 26, 2021, 2:10:42 PM4/26/21
to Google Mobile Ads SDK Developers
Hi. I don't think the issue is related to the Unity version.  The issue is related to the Play-Services version. I created a new project and Import Google Mobile Ads Unity Plugin 5.4.0 and Facebook Mediation Adapter 3.2.0. I did what you said. But, Play Services Resolver still automatically integrates Play-Services version 20.0.0.

admob2.png


For example, if I did these 1 month ago, it would work without any problems. Because Play Services Resolver would automatically integrate Play-Service-19.7.0 version. But Play-Services-20.0.0 version has just been released and now integrates it.

26 Nisan 2021 Pazartesi tarihinde saat 18:42:34 UTC+3 itibarıyla mobileadssdkforumadvisor şunları yazdı:

Mobile Ads SDK Forum Advisor Prod

unread,
Apr 26, 2021, 4:09:31 PM4/26/21
to eraya...@gmail.com, google-adm...@googlegroups.com
Hi,

I was able to get the following setup to work:
    • Unity version: 2019.4.21f1
    • Google Mobile Ads Unity plugin version: 5.4.0 (last)
    • Platform: Android
    • Mediation ad networks used, and their versions: Facebook Audience Network 3.2.0
    • sample "Hello World" app
    The force resolve that leads to Play Services 20.0 still allows the plugin and Facebook to work together.  Are there any other steps to see an issue?

    Alain-Daniel Bourdages

    unread,
    Apr 26, 2021, 4:41:59 PM4/26/21
    to Google Mobile Ads SDK Developers
    I am in the same situation as the original poster. Sometime in the last week, a 5 year old, live game suddenly started giving out error messages in testing. Rolling back all the changes points to problems with the GoogleMobileAd SDK not correctly supporting 20.0.0 (it worked fine while the resolver was pulling 19.8.0)

    The first error I was getting was: java.lang.NoSuchMethodError: no static method with name='initialize' signature='(Lcom.unity3d.player.UnityPlayerActivity;Ljava/lang/String;)V'. This was the result of calling MobileAds.Initialize("appId"). Looking into 20.0.0 I realize this method doesn't exist anymore but it is still called by the SDK.

    Right now, I'm trying to update the calls for rewarded ads but (AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/reward/RewardedVideoAd;) to the new 20.0.0 way of doing things but I'm not even sure whether the SDK implements the right classes, I will see shortly.

    Maybe if we can massage the Resolver to pull out the 19.8.0 libraries instead of 20.0.0 we are OK but to be crystal clear, the 5.4.0 SDK doesn't support 20.0.0 and should be updated. It implements references to methods and classes that are no longer in existence. And it causes a ton of exceptions. Just take a look at the 20.0.0 migration guide which state that MobileAds.initialize(Context, String) has been removed. Then look at the SDK's GoogleMobileAds/Platforms/Android/MobileAdsClient.cs at line 45, which makes a JNI call to that method.

    Also please note that other plugins might force the resolver to pull the 20.0.0 libs, our projects are a little more complicated than the sample and we don't necessarily have the full control over that.

    Cheers,
    Alain-Daniel

    eraya...@gmail.com

    unread,
    Apr 26, 2021, 5:31:42 PM4/26/21
    to Google Mobile Ads SDK Developers
    Did you build and run the app on your device? Because I'm doing what you say, but still gives error , running app on Android Device.

    26 Nisan 2021 Pazartesi tarihinde saat 23:09:31 UTC+3 itibarıyla mobileadssdkforumadvisor şunları yazdı:

    eraya...@gmail.com

    unread,
    Apr 26, 2021, 5:33:05 PM4/26/21
    to Google Mobile Ads SDK Developers
    +1. 

    I think Google Mobile Ads Unity Plugin should be updated and compatible with Play-Services-20.0.0 version.

    26 Nisan 2021 Pazartesi tarihinde saat 23:41:59 UTC+3 itibarıyla Alain-Daniel Bourdages şunları yazdı:

    Mobile Ads SDK Forum Advisor Prod

    unread,
    Apr 26, 2021, 10:47:04 PM4/26/21
    to eraya...@gmail.com, adbou...@gmail.com, google-adm...@googlegroups.com

    Hi All,

    Thank you for providing us information about this concern.

    I know how frustrating it can be and as much as we would want to assists you on this. I'm afraid we can't replicate this on our end to investigate. If you could please provide us any sample app with minimum modification that showing the error you encountered, it will help us to investigate this further.

    Regards,

    Google Logo
    Princess Pamela Pineda
    Mobile Ads SDK Team
     


    ref:_00D1U1174p._5004Q2GHNQa:ref

    eraya...@gmail.com

    unread,
    Apr 27, 2021, 7:16:05 AM4/27/21
    to Google Mobile Ads SDK Developers
    I told you everything. Complaints will increase.

    Others have this problem too:

    https://github.com/googleads/googleads-mobile-unity/issues/1591

    27 Nisan 2021 Salı tarihinde saat 05:47:04 UTC+3 itibarıyla mobileadssdkforumadvisor şunları yazdı:
    Message has been deleted
    Message has been deleted

    Mobile Ads SDK Forum Advisor

    unread,
    Jun 24, 2021, 6:13:33 AM6/24/21
    to eraya...@gmail.com, google-adm...@googlegroups.com

    Hi Eray,

    I hope you're doing well.

    I just want to circle back on this. The team mentioned that this has been fixed. Please let me know if you still encounter the issue so I could raise this to the team once again.

    Reply all
    Reply to author
    Forward
    0 new messages