Good afternoon. I'm trying to implement Google Ad Manager to the project (not AdMob) to render the advertising content.
According to my needs, I'm using Native ads (not Banner) with the AdSize.FLUID. For some reason when I'm trying to set AdListener to PublisherAdView. onAdClicked() callback doesn't trigger (other callbacks works perfectly). Has somebody faced that strange issue and how have you solved it?
P.S. onAdClicked() callback works if I load advertising content via AdLoader.Builder(), but I cannot use it due to the project structure.
P.P.S I'm using the following version of the play services ads version
implementation 'com.google.android.gms:play-services-ads:19.6.0'
PublisherAdView publisherAdView = new PublisherAdView(context);
publisherAdView.setAdUnitId(AD_UNIT_ID);
publisherAdView.setAdSizes(AdSize.FLUID);
publisherAdView.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
}
@Override
public void onAdFailedToLoad(LoadAdError loadAdError) {
Log.e("!", "onAdFailedToLoad: ");
super.onAdFailedToLoad(loadAdError);
}
@Override
public void onAdOpened() {
Log.e("!", "onAdOpened: " );
super.onAdOpened();
}
@Override
public void onAdLoaded() {
Log.e("!", "onAdLoaded: " );
super.onAdLoaded();
}
@Override
public void onAdClicked() {
super.onAdClicked();
Log.e("!", "onAdClicked: ");
}
});
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
publisherAdView.loadAd(builder.build());
I've didn't find how to solve this issue. I had some restrictions because of project structure, so I've wrapped Google ads view with a custom view (nothing special, just a container with ad view and placeholder + some methods for building ad, and changing placeholder visibility).
With this solution, I'm able to use AdLoader.Builder().