In this case I used Facebook audience network for show ads in my Android apps but I all time got an error that is "no fill".
Here is my code
public class FacebookAdsShowActivity extends AppCompatActivity {
private AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_facebook_ads_show);
adView = new AdView(this, "2604007993014170_2604011093013860", AdSize.BANNER_HEIGHT_50);
LinearLayout adContainer = (LinearLayout) findViewById(R.id.banner_container);
adContainer.addView(adView);
adView.setAdListener(new AdListener() {
@Override
public void onError(Ad ad, AdError adError) {
Toast.makeText(FacebookAdsShowActivity.this, "Error: " + adError.getErrorMessage(),Toast.LENGTH_LONG).show();
}
@Override
public void onAdLoaded(Ad ad) {
}
@Override
public void onAdClicked(Ad ad) {
}
@Override
public void onLoggingImpression(Ad ad) {
}
});
adView.loadAd();
}
@Override
protected void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
My build.gradle(app module) dependency are:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.facebook.android:audience-network-sdk:5.6.0'
//noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:25.3.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}