I'm using 6.5.1 with no problems:
implementation 'com.facebook.android:audience-network-sdk:6.5.1'
bannerListener = new AdListener() {
@Override public void onError(Ad ad, AdError adError) {}
@Override public void onAdLoaded(Ad ad) {}
@Override public void onAdClicked(Ad ad) {}
@Override public void onLoggingImpression(Ad ad) {}
};
loading = true;
banner = new AdView(context, id, AdSize.BANNER_HEIGHT_50);
banner.loadAd(banner.buildLoadAdConfig().withAdListener(bannerListener).build());
But if I update the sdk to 6.11.0
or even 6.6.0
, i'm getting this exception:
java.lang.NoSuchMethodError: No interface method onAdEventManagerCreated(Landroid/content/Context;)V in class Lcom/facebook/ads/internal/api/InitApi; or its super classes (declaration of 'com.facebook.ads.internal.api.InitApi' appears in /data/data/com.myapp.core/code_cache/.overlay/base.apk/classes.dex)
at com.facebook.ads.redexgen.X.U4.A04(:55533)
at com.facebook.ads.redexgen.X.U4.<init>(:55521)
at com.facebook.ads.redexgen.X.U4.A01(:55528)
at com.facebook.ads.redexgen.X.X3.A5Z(:65854)
at com.facebook.ads.redexgen.X.8J.A08(:18206)
at com.facebook.ads.redexgen.X.cS.<init>(:71757)
at com.facebook.ads.redexgen.X.F8.<init>(:32983)
at com.facebook.ads.redexgen.X.4x.<init>(:12836)
at com.facebook.ads.internal.dynamicloading.DynamicLoaderImpl.createAdViewApi(:133)
at com.facebook.ads.AdView.<init>(AdView.java:102)
at com.myapp.ad.facebook.FacebookAdEntity.init(FacebookAdEntity.java:86)
The error line is banner = new AdView(context, id, AdSize.BANNER_HEIGHT_50);
Does anyone have any idea about what is happening?
I'm building with api 31:
android {
compileSdkVersion 31
buildToolsVersion '31.0.0'
defaultConfig {
minSdkVersion 21
targetSdkVersion 31
}
Well, I simply deleted Android Studio cache and restarted it... now it works...
Seems that some bug on it was producing the issue. Don't sure what, but a restart with cache cleaning solved it.