Reputation: 192
i have create facebook ad demo app, but can't load any ad(Interstitial ,Native ,Banner) in any version sdk.
if i using sdk version 5.3.0 then facebook ad return error.
Error: New bundles must use latest available Audience Network SDK.
if i using sdk version 5.5.0,5.6.0 then facebook ad return error.
Error: No fill
i also tried live ad id(264476213973610_264482430639655) and testing ad id (YOUR_PLACEMENT_ID) but doesn't work
AudienceNetworkAds.initialize(this);
final InterstitialAd interstitialAd = new InterstitialAd(MainActivity.this, "YOUR_PLACEMENT_ID");
AdSettings.addTestDevice("6f2e675e-05b0-46d8-b3d6-032ef6a25fdb");
interstitialAd.destroy();
interstitialAd.setAdListener(new InterstitialAdListener() {
@Override
public void onInterstitialDisplayed(Ad ad) {
Log.e(TAG, "Interstitial ad displayed.");
}
@Override
public void onInterstitialDismissed(Ad ad) {
Log.e(TAG, "Interstitial ad dismissed.");
}
@Override
public void onError(Ad ad, AdError adError) {
Toast.makeText(MainActivity.this, "Error: " + adError.getErrorMessage(), Toast.LENGTH_LONG).show();
}
@Override
public void onAdLoaded(Ad ad) {
Toast.makeText(MainActivity.this, "Loaded: " + ad.getPlacementId(), Toast.LENGTH_LONG).show();
interstitialAd.show();
}
@Override
public void onAdClicked(Ad ad) {
Log.d(TAG, "Interstitial ad clicked!");
}
@Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "Interstitial ad impression logged!");
}
});
interstitialAd.loadAd();
Upvotes: 1
Views: 2191
Reputation: 192
use sdk version com.facebook.android:audience-network-sdk:5.11.0
Upvotes: 0
Reputation: 859
I had faced a similar issue. So I'll explain how I solved it.
To test properly on your device, you need to follow some other steps too other than you mentioned in the question.
STEPS:
Add test device to get test ads (or live ads for testing which doesn't give you revenue). To add a device:
i) Login to your Audience Network account
ii) Go to Monetization Manager > Integration > Testing
iii) Add test device using Android's AAID or iOS's IDFA. You can check other SO's threads to find AAID or IDFA of the device, in case you don't know.
iv) You can test it in the device now and you must be getting ads. If still there are no ads, select Use real advertiser content option there itself. Now to test different type of ads like HD Video, Simple Image or such; Click Select Ad Type on the same screen
NOTE: Remember to check the article on FAN's ad Caching in Android 9+ because HD Video or any type of video ads won't show on Android 9+ and you might get a blank screen blocking all the functionalities of your app.
Upvotes: 1