Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.unity.ads.UnityAdListener

1,371 views
Skip to first unread message

Ferdinand Buagas

unread,
Oct 10, 2017, 2:44:50 AM10/10/17
to Google Mobile Ads SDK Developers
I am Using latest Unity 2017 1.1.f1.

My Code is working before and the test ad showed in my emulator. Just now I'm wondering why it doesn't show. And as I check the logcat, it shows this error.

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.unity.ads.UnityAdListener 
Please also see the screenshot below.

Need help on this, am I missing something? :(



I am new to Unity :)

The Code:


using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;

public class AdScript : MonoBehaviour
{

bool hasShownAdOneTime;


void Awake()
{
//Request Ad
RequestInterstitialAds();
}

void Update()
{
if (GameControl.isGameOver)
{
if (!hasShownAdOneTime)
{
hasShownAdOneTime = true;
//Invoke("showInterstitialAd", 3.0f);
Invoke("showInterstitialAd", .1f);
}
}
}

public void showInterstitialAd()
{
//Show Ad
if (interstitial.IsLoaded())
{
interstitial.Show();

//Stop Sound
//

//Debug.Log("SHOW AD XXX");
}

}

InterstitialAd interstitial;
private void RequestInterstitialAds()
{
//Testing
string adID = "ca-app-pub-3940256099942544/1033173712";

 

#if UNITY_ANDROID
string adUnitId = adID;
#elif UNITY_IOS
string adUnitId = adID;
#else
string adUnitId = adID;
#endif
// Initialize an InterstitialAd.
interstitial = new InterstitialAd(adUnitId);

//Test
AdRequest request = new AdRequest.Builder()
.AddTestDevice(AdRequest.TestDeviceSimulator)       // Simulator.
.AddTestDevice("89D1DA1F820CE28BA86223A1C3443450")  // My test device.
.Build();

//Production
//AdRequest request = new AdRequest.Builder().Build();

//Register Ad Close Event
interstitial.OnAdClosed += Interstitial_OnAdClosed;

//Load the interstitial with the request.
interstitial.LoadAd(request);

//Debug.Log("AD LOADED XXX");

}

//Ad Close Event
private void Interstitial_OnAdClosed(object sender, System.EventArgs e)
{
//Resume Play Sound

}
}


Joshua Lagonera (Mobile Ads SDK Team)

unread,
Oct 10, 2017, 4:45:20 AM10/10/17
to Google Mobile Ads SDK Developers
Hi there,

It seems that your project's setting was changed to the point that it can't find or build the right files. Can you try re-importing the official Unity Plugin into your project and go to the Assets menu, go to Android > Play Services Resolver and select Resolve Client Jars and check if it helps resolve the issue?

If you are still experiencing the issue after doing the steps above, then can you provide us a sample project where the issue can be replicated so we may take a closer look?

Regards,
Joshua Lagonera
Mobile Ads SDK Team

Ferdinand Buagas

unread,
Oct 10, 2017, 5:46:06 AM10/10/17
to Google Mobile Ads SDK Developers

 Hello Joshua,


Thanks for the immediate response :) 
Btw, After doing the steps you've provided, I encounter this issue when building. :( 
Also, I see some duplicate  files in Assets/Plugins/Android, is this fine?



Where can I send the files?


Thanks Joshua.



Ferdinand Buagas

unread,
Oct 10, 2017, 7:00:10 AM10/10/17
to Google Mobile Ads SDK Developers

Hello Joshua,


The duplicate issue has been resolved, and I only have one issue now.


Everything seems fine and no errors except for this:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.unity.ads.UnityAdListener" (see screenshot 1)


I can't get the test interstitial ad on my device.

And as per checking in console the interstitial ad has been loaded. (see screenshot 2)


The unity-plugin-library.jar is located in Assets/Plugins/Android/GoogleMobileAdsPlugin/Lib (see screenshot 3)

Also Tried to put the unity-plugin-library.jar in this path Assets/Plugins/Android but still no success.

Am I missing something on this? Tried also to re-import all the packages but still no luck.



3



2


1

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Oct 10, 2017, 11:11:28 PM10/10/17
to Google Mobile Ads SDK Developers
Hi there,

Can you provide us a sample project where the issue can be observed? I am not able to get this error when I try to build our sample app on my end. Can you check if you can see the error when you build our sample apps?

As for your project, you can just attach it to one of your posts. However, let us know if you would prefer providing it to us privately.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

Joshua Lagonera (Mobile Ads SDK Team)

unread,
Oct 18, 2017, 3:25:21 AM10/18/17
to Google Mobile Ads SDK Developers
Hi Ferdinand,

Hope you are doing well.

Are you still experiencing the issue you reported? Kindly let us know if you still need assistance from our end and provide us the previously requested information if so.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

ravisha...@gmail.com

unread,
Apr 1, 2018, 5:44:10 PM4/1/18
to Google Mobile Ads SDK Developers
Hi Ferdinand, 
I am facing the same problem in the exact same version of Unity. 

Could you please let me know how did you resolve the issue? 
Surprisingly, if I just make a test sample project, I don't get this problem. But on my main project I get this problem.. so I am assuming that it has something to do with the way my main project is configured. 

Regards, 
Ravi 

mobileadssdk-a...@google.com

unread,
Apr 2, 2018, 1:07:50 AM4/2/18
to ravisha...@gmail.com, Google Mobile Ads SDK Developers
Hi Ravi,

Can you confirm if you have followed our official Mediation Guide for UnityAds? As you have mentioned, the issue is with your project and not specific to the Mobile Ads SDK since you were not able to reproduce the issue with a test project. I would recommend that you double check your integration to figure out which may have caused the issue.

However, you may provide to us a sample project (preferably by using the Reply Privately to Author option) where the issue can be replicated for us to check on our end.

Regards,
Joshua Lagonera
Mobile Ads SDK Team

--

---
You received this message because you are subscribed to the Google Groups "Google Mobile Ads SDK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-admob-ads-sdk+unsub...@googlegroups.com.
To post to this group, send email to google-admob-ads-sdk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-admob-ads-sdk/d4be6947-60be-4cd9-9c35-1b4d5636aecf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages