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…
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 , 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
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.)
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 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.
Honestly, I don’t know the exact cause…
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.
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.)
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
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…