arunoday singh
arunoday singh

Reputation: 222

my ads are not showing up

i am just trying to learn how to add ads in android app.but the ads are not showing up.i don't know why its not coming up

here is my mainactivity.xml

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />


<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"
android:layout_marginTop="443dp"
android:layout_below="@+id/textView"       
android:layout_alignParentEnd="true">
</com.google.android.gms.ads.AdView>
</RelativeLayout>

Mainactivity.java

package com.example.a1407268.admob;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
    }
 }

Upvotes: 1

Views: 501

Answers (1)

AAryan
AAryan

Reputation: 20140

If you're testing your app then use addTestDevice() to check Ad alignment.

AdView adView = new AdView(this);

AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
adView.loadAd(adRequestBuilder.build());

Otherwise If your App is live then and not able to show any Ad then you've to wait for some time.

According to Google

"It could be that you have only recently created a new Ad Unit ID and requesting for live ads. It could take a few hours for ads to start getting served if that is that case. If you are receiving test ads then your implementation is fine. Just wait a few hours and see if you are able to receive live ads then. If not, can send us your Ad Unit ID for us to look into."

https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/fBe3YL3ffpo

Upvotes: 1

Related Questions