Admob (Test Ad Not Loading) AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityRewardedAdCallback

Hello, i have implemented admob before in my other games, but never seen this issue…

im using my app id in the GMD Setting and i have tried using my Own Rewarded + Test Ad Id… none of them work… the ads dont load at all… my admob account is okay & i have other games using it…

here is the full log:

2024/10/20 23:02:26.896 30616 30650 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityRewardedAdCallback //-------------AD Mob..... hehh..
2024/10/20 23:02:26.896 30616 30650 Error Unity java.lang.ClassNotFoundException: com.google.unity.ads.UnityRewardedAdCallback
2024/10/20 23:02:26.896 30616 30650 Error Unity 	at java.lang.Class.classForName(Native Method)
2024/10/20 23:02:26.896 30616 30650 Error Unity 	at java.lang.Class.forName(Class.java:454)
2024/10/20 23:02:26.896 30616 30650 Error Unity 	at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
2024/10/20 23:02:26.896 30616 30650 Error Unity 	at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
2024/10/20 23:02:26.896 30616 30650 Error Unity 	at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
2024/10/20 23:02:26.896 30616 30650 Error Unity 	at android.os.Handler.dispatchMessage(Handler.java:102)
2024/10/20 23:02:26.896 30616 30650 Error Unity 	at android.os.Looper.loop(Looper.java:223)
2024/10/20 23:02:26.896 30616 30650 Error Unity 	at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
2024/10/20 23:02:26.896 30616 30650 Error Unity Caused by: java.lang.ClassNotFoundException: com.google.unity.ads.UnityRewardedAdCallback
2024/10/20 23:02:26.896 30616 30650 Error Unity 	... 8 more
2024/10/20 23:02:26.896 30616 30650 Error Unity   at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0 
2024/10/20 23:02:26.896 30616 30650 Error Unity   at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0 
2024/10/20 23:02:26.896 30616 30650 Error Unity   at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String classNa
2024/10/20 23:02:28.270 30616 30616 Error chromium [ERROR:aw_browser_terminator.cc(166)] Renderer process (30895) crash detected (code -1).
2024/10/20 23:02:46.439 30616 30833 Info TRuntime.CctTransportBackend Making request to: https://firebaselogging.googleapis.com/v0cc/log/batch?format=json_proto3

the main problem is AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityRewardedAdCallback… i dont know how to fix this…

Environment:

  • Unity 2021 LTS
  • Admob v9.2.1
  • Test ad id + Real Ad Id

What I Have Tried:

  • Reimporting the .unityPackage.
  • Locating the .aar file(its there)
  • Force Resolve + Resolve…

i have my game published in play store… i need help as soon as possible… :cry::cry:

im so, so dead…

is there anyone here?

bruh noooooooooooo one?

Hello, can you please share the code related to payment of advertising compensation?
That part may be the problem.
If possible, I would appreciate it if you could also share the part about resetting the advertisement.

Hello, @MCF24 Thanks for Coming Here! Here Is My Code For Load & Show Ad:

public void Start()
{
    //? Initialize the Admob SDK.
    MobileAds.RaiseAdEventsOnUnityMainThread = true;
    MobileAds.Initialize((InitializationStatus initStatus) =>
    {
        //* This callback is called once the MobileAds SDK is initialized.
        Debug.Log("Admob Initialized.");
    });

    MobileAds.SetApplicationMuted(true);
        LoadRewardedAd();
}

//? Call Of Showing Ad:
public void fnr_ShowRewardedAd() //^ fnr - For No Resone
{
    if (_rewardedAd != null && _rewardedAd.CanShowAd())
    {
        //* If Ad Was Showen Sucsessfuly Then...
        _rewardedAd.Show((Reward reward) =>
        {
            // TODO: Reward the user.
            //^ hehe.
            LoadRewardedAd();
        });
    }
}

//~ Call For Loading Ad:
public void LoadRewardedAd()
{
    //~ Destroying The Old Ad Befor Adding The New One :)
    if (_rewardedAd != null)
    {
            _rewardedAd.Destroy();
            _rewardedAd = null;
    }

    //? The Ad Is Loading:
    if(_loadingAd != null){_loadingAd.SetActive(true);}

    //^ Creating An Request Load The Ad.
    var adRequest = new AdRequest();

    //? send the request to load the ad.
    RewardedAd.Load(_adUnitId, adRequest,
        (RewardedAd ad, LoadAdError error) =>
        {
            //! if error is not null, the load request failed.
            if (error != null)
            {
                Debug.LogError("Rewarded ad failed to load an ad with error : " + error);
                return;
            }

            if (ad == null)
            {
                Debug.LogError("Unexpected error: Rewarded load event fired with null ad and null error.");
                return;
            }

            //^ Ad Loaded:
            Debug.Log("Rewarded ad loaded with response : "
                        + ad.GetResponseInfo());
            
            if(_loadingAd != null){_loadingAd.SetActive(false);}

            _rewardedAd = ad;
        });
}

If possible, I would appreciate it if you could also share the part about resetting the advertisement.

i did not understand :sweat_smile:, i just reimported the .unityPackage (by google) becaouse i heard some people say it fixes it…

What i believe After Research:

  • Its Some How Missing The com.google.unity.ads.UnityRewardedAdCallback.(but it donts makes any sense)
  • I Have The Progaurd File:
    -keep class com.google.unity.** { *; } -keep public class com.google.android.gms.ads.**{ public *; } -keep public class com.google.ads.**{ public *; } -keepattributes *Annotation* -dontobfuscate
  • I Dont Know What To Do…

Are you getting an error when you first load the ad?
Or does an error occur when paying rewards after watching an ad?

If an error occurs after watching an advertisement
In the code above, LoadRewardedAd(); Could you check if the ad appears normally after deleting that part?

(I couldn’t check the previous posts because I was busy doing other things on the weekends. Sorry for not being able to help you.)

1 Like

Are you getting an error when you first load the ad?
Or does an error occur when paying rewards after watching an ad?

I Get The Error when i first load the ad at the start…
ad initializes successfully tho…

If an error occurs after watching an advertisement

when i click on an button which shod display an rewarded ad i get Ad could not Be Shown.

(I couldn’t check the previous posts because I was busy doing other things on the weekends. Sorry for not being able to help you.)

No no its okay! You helped me a lot! i hope you had an great weekend!

1 Like

Does this mean that an error occurs when running ShowRewardedAd?

If so, initialize MobileAds once more when _rewardedAd is null and make it possible to load ads.
Additionally, it would be a good idea to load the ad once more when the CanShowAd status of _rewardedAd is False.

initialize MobileAds once more when _rewardedAd is null and make it possible to load ads.
Additionally, it would be a good idea to load the ad once more when the CanShowAd status of _rewardedAd is False.

okay let me go and try it…

Does this mean that an error occurs when running ShowRewardedAd?

The Problem accures when ‘Loading The Ad’ When LoadRewardedAd() Is Called. Which Gives AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityRewardedAdCallback & When The Ad DID NOT load… and i clicking on button it gives me Ad could not Be Shown.

Hello @MCF24 , Unfortunately the problem donts go away :sob::sob: when calling LoadRewardedAd() i get the same error and well… it causes (maybe) the rewarded ad to be always null.(because it never was able to load one…)

Have you filled in all the data correctly in Asset → Google Mobile Ads → settings at the top of Unity?
The ID that must be written at that location and the ID written inside the code have different values.
I think it would be a good idea to check this too.

yes there is my app id there… + inside androidManifest.xml

in the code i have my rewarded ad unit id.

i also see this warning

2024/10/29 20:49:10.709 19136 19218 Warn System ClassLoader referenced unknown path: 
2024/10/29 20:49:10.730 19136 19218 Warn eachingthelimi ClassLoaderContext classpath size mismatch. expected=10, found=2 (DLC[];PCL[base.apk*142403325:base.apk!classes2.dex*315429746:base.apk!classes3.dex*1828925760:base.apk!classes4.dex*670051805:base.apk!classes5.dex*577491003:base.apk!classes6.dex*3794012015:base.apk!classes7.dex*3887599700:base.apk!classes8.dex*2306949656:base.apk!classes9.dex*1186708358:base.apk!classes10.dex*1522424988]{PCL[/system/framework/org.apache.http.legacy.jar*181645345]#PCL[/system/framework/com.android.media.remotedisplay.jar*2596221954]#PCL[/system/framework/com.android.location.provider.jar*2383074192]#PCL[/system/framework/org.apache.http.legacy.jar*181645345]} | DLC[];PCL[/data/app/~~oem_p3XaA0nD85qE_L2g-g==/com.foursgamz.reachingthelimit-UQKb9Ix1CdAhHahGm9DGkw==/base.apk*493166965:/data/app/~~oem_p3XaA0nD85qE_L2g-g==/com.foursgamz.reachingthelimit-UQKb9Ix1CdAhHahGm9DGkw==/base.apk!classes2.dex*447078667])
2024/10/29 20:49:10.732 19136 19218 Warn eachingthelimi Found duplicate classes, falling back to extracting from APK : /data/app/~~QIucXEwfwbq7njknP9I1zA==/com.google.android.gms-1yEIQ52PPfgD6QqTU7c4Tg==/split_MeasurementDynamite_installtime.apk
2024/10/29 20:49:10.732 19136 19218 Warn eachingthelimi NOTE: This wastes RAM and hurts startup performance.
2024/10/29 20:49:10.732 19136 19218 Warn eachingthelimi Found duplicated class when checking oat files: 'Landroid/support/v4/graphics/drawable/IconCompatParcelizer;' in /data/app/~~oem_p3XaA0nD85qE_L2g-g==/com.foursgamz.reachingthelimit-UQKb9Ix1CdAhHahGm9DGkw==/base.apk and /data/app/~~QIucXEwfwbq7njknP9I1zA==/com.google.android.gms-1yEIQ52PPfgD6QqTU7c4Tg==/split_MeasurementDynamite_installtime.apk
2024/10/29 20:49:10.842 19136 19218 Warn DynamiteModule Local module descriptor class for com.google.android.gms.measurement.dynamite not found.

Honestly, I don’t know the exact cause… :cry:
Could you tell me what version of ads you are using?
I am using version 9.1.0 and have not found any problems with this version.

Hello @MCF24,
im using the Admob v9.2.1. shod i downgrade to v9.1.0? and… how do i do that? just import the v9.1.0 in unity?

Downgrading is not required, but if you are trying several times to solve the problem, changing the version may be a good idea.
If you change the version, it would be safest to delete all Admob files of the current version before installing that version.
(Still, you never know what might happen, so we recommend a backup to GitHub, etc.)

i have a bacup made in github (hopefully), im doing waht chat gpt says :sweat_smile:

  1. Remove the Current AdMob SDK:
  • Go to your Unity project’s Assets folder.
  • Locate the GoogleMobileAds folder or any folder related to AdMob.
  • Delete these folders to remove all files associated with v9.2.1.
  1. Download the AdMob v9.1.0 SDK:
  1. Import the Older SDK:
  • Open Unity and go to Assets > Import Package > Custom Package.
  • Select the AdMob v9.1.0 .unitypackage you just downloaded.
  • Import all the files.
  1. Update mainTemplate.gradle if Needed:
  • Since you’re using a custom mainTemplate.gradle, make sure it aligns with the dependencies for AdMob v9.1.0.
  • Check the GitHub release notes or documentation for any specific gradle changes needed for that version.
  1. Clear the Cache and Rebuild:
  • Go to Edit > Preferences > Cache Server in Unity and clear the cache.
  • Rebuild your project to ensure it uses the downgraded SDK.

This should replace the newer AdMob SDK with v9.1.0.

1 Like

@MCF24 Dame… i have tried every single thing… it donts work… i get the same error

2024/10/29 20:49:10.709 19136 19218 Warn System ClassLoader referenced unknown path: 
2024/10/29 20:49:10.730 19136 19218 Warn eachingthelimi ClassLoaderContext classpath size mismatch. expected=10, found=2 (DLC[];PCL[base.apk*142403325:base.apk!classes2.dex*315429746:base.apk!classes3.dex*1828925760:base.apk!classes4.dex*670051805:base.apk!classes5.dex*577491003:base.apk!classes6.dex*3794012015:base.apk!classes7.dex*3887599700:base.apk!classes8.dex*2306949656:base.apk!classes9.dex*1186708358:base.apk!classes10.dex*1522424988]{PCL[/system/framework/org.apache.http.legacy.jar*181645345]#PCL[/system/framework/com.android.media.remotedisplay.jar*2596221954]#PCL[/system/framework/com.android.location.provider.jar*2383074192]#PCL[/system/framework/org.apache.http.legacy.jar*181645345]} | DLC[];PCL[/data/app/~~oem_p3XaA0nD85qE_L2g-g==/com.foursgamz.reachingthelimit-UQKb9Ix1CdAhHahGm9DGkw==/base.apk*493166965:/data/app/~~oem_p3XaA0nD85qE_L2g-g==/com.foursgamz.reachingthelimit-UQKb9Ix1CdAhHahGm9DGkw==/base.apk!classes2.dex*447078667])
2024/10/29 20:49:10.732 19136 19218 Warn eachingthelimi Found duplicate classes, falling back to extracting from APK : /data/app/~~QIucXEwfwbq7njknP9I1zA==/com.google.android.gms-1yEIQ52PPfgD6QqTU7c4Tg==/split_MeasurementDynamite_installtime.apk
2024/10/29 20:49:10.732 19136 19218 Warn eachingthelimi NOTE: This wastes RAM and hurts startup performance.
2024/10/29 20:49:10.732 19136 19218 Warn eachingthelimi Found duplicated class when checking oat files: 'Landroid/support/v4/graphics/drawable/IconCompatParcelizer;' in /data/app/~~oem_p3XaA0nD85qE_L2g-g==/com.foursgamz.reachingthelimit-UQKb9Ix1CdAhHahGm9DGkw==/base.apk and /data/app/~~QIucXEwfwbq7njknP9I1zA==/com.google.android.gms-1yEIQ52PPfgD6QqTU7c4Tg==/split_MeasurementDynamite_installtime.apk
2024/10/29 20:49:10.842 19136 19218 Warn DynamiteModule Local module descriptor class for com.google.android.gms.measurement.dynamite not found.

AndroidJavaException: java.lang.ClassNotFoundException: com.google.unity.ads.UnityRewardedAdCallback

Hello @MCF24, with the help of god i have finally, yes FINALLY fixed the bug… i also dont know how i fixed it but… i would say i have switched admob versions probably 4 times… from here (v8.7.0 to v9.1.0 to v9.2.1) and finally when i went to v9.3.0 i got tons of gradle build error + so many others manifest, minSDK…blah…blahh… and after dying an some how fixing them i managed to fix the issue! now i have to see does the real ads show up :sweat_smile:

I was thinking to leave the admob and go to ‘Unity Ads’, but the main problem is… unity ads dont has Native Ad System! which i really like and probably gono add in future…

anyway thanks for your help!

1 Like