my ads are not showing up - android

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);
}
}

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

Related

Campaign Ads (House Ads)

my admob ads works perfectly (mediation by admob, running like 7 activities where i have these ads) but when i started campaign in one of my activity with one simple AD (320x50) it doesnt show. Tried every type of campaign noone worked.
Is there anything what i need to do? Something in code? or in Admob settings (except cpm, chose which activity, type of AD etc... already done that). I was searching for this problem the whole week but didnt find any succes.
If someone could help me it will be awesome because there is no support on AdMob except of FAQ which tells you nothing.
There is a sample of code activity and layout:
<LinearLayout
android:id="#+id/tejbl_tlacitka"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:orientation="vertical"
>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
style="#style/bannerpozadi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-4412963312739253/5142509411" />
</LinearLayout>
Activity:
public class oAplikaciActivity extends AppCompatActivity {
private AdView mAdview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_oaplikaci);
setTitle("O aplikaci");
mAdview = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdview.loadAd(adRequest);

Ad Mob ads not showing regularly

I'm testing the ad mobs ads on a real device. Sometimes the ads shows up and sometimes it doesn't shows. I've no idea what the problem is.
While testing on a virtual device I used test ads and they always shows up but now I'am using real ads on a device with real app-id and unit-id.
Below is the code I'm using. Any help would be highly appreciated.
Java Code:
MobileAds.initialize(this,"ca-app-pub-8665656565286300~4683225285");
mAdview = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdview.loadAd(adRequest);
XML:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-8665656565286300/8888341401"
/>

Admob test ad working but not real ad

I added everything to android application as per the instructions from the admob website. On both the emulator and phone i tested my app. The test ads were displaying properly. i generated a signed apk and still it is showing the test ads. what should i do?
here my code:
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
in MainActivity:
MobileAds.initialize(getApplicationContext(), "ca-app-pub-9815982880222619/9339487889");
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Please help me!

Adding AdMob banner causes infinite GCAndroid deconstrcutor

After Admob banner loaded, LogCat console begins to show GCAndroid deconstrucor lines non-stop:
Even if i close my app it still continues.
I'm using Eclipse with targeting Andoid SDK 21, min SDK is 11. Google Play Service included as project as per AdMob guide. Play Service SDK ver 6.5.
This is just for test and simply copied from Android Developer Training guide
package com.example.admob;
import com.google.android.gms.ads.*;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class Main extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_main);
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}
}
and layout is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="#string/admob_banner_id"
ads:adSize="BANNER" />
</LinearLayout>
The logcat lines are Android garbage collector. It just means that the garbage collector is running regularly. Nothing to be concerned about.
I suspect that if you comment out adView.loadAd(adRequest) you will still see them.

Android, admob advert is not displaying

I am trying to implement a banner advert in my Android application. I have used Gradle to download the dependencies, etc.
In my activity where I want the advert to be displayed I have:
<com.google.android.gms.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/ad_mob_id" />
And ad_mob_id is
ca-app-pub-3940256099942544/6300978111
Which is for test ads, I took that from https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start#step_1_modify_the_main_activity_layout
However when I run the activity nothing is displayed and there are no errors/warnings generated.
Am I missing another step?
AdView mAdView = (AdView) getView().findViewById(R.id.adView); // locate the id the banner view
// if you do not use fragments and you are using it directing the remove the getView();
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest); // load it..that's all and you will see logs on it
i took it from the link you posted, it has all you need.

Categories

Resources