Admob ads not showing, not even test ads











up vote
1
down vote

favorite












I don't get what I'm doing wrong, I wanted to show a banner on the bottom but not even the test ads show up. I followed their tutorial and my app looks like this:




xml with the ad (it does show up on the preview)




<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/infoPageBackgroundColor"
android:orientation="vertical"
android:paddingTop="8dp"
tools:context=".AppInfoActivity">

...

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:adSize="SMART_BANNER"
app:adUnitId="@string/banner_id"/>





Metadata in AndroidManifest




<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/app_id"/>



Project gradle.build




buildscript {

repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}

}
dependencies {
...
}
}



App gradle.build




dependencies {
...
}



Entry Activity




import com.google.android.gms.ads.MobileAds;


public class EntryActivity extends BaseActivity {
private View progressBar;
private LoadListAsyncTask loadListAsyncTask;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
...

MobileAds.initialize(this, "@string/app_id");
}



Java file




...

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

...


public class StickerPackListActivity extends BaseActivity {
...

private AdView mAdView;

@Override
protected void onCreate(Bundle savedInstanceState) {
...

mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
...


I'm using the banner test ID to try it and it only shows up in the xml editor. Any idea of why? Even if I try my ID it deosn't work. Sorry for not being able to explain much more as it's just like this. Did I forget something?










share|improve this question
























  • What permissions do you have included in the manifest? Are you also getting any errors at all about this in the console? Where exactly are you initialising the SDK?
    – daedsidog
    Nov 10 at 10:50












  • none, what am I supposed to add? I'm initialising it in an entry activity that sets up the app but I could change it somewhere else
    – b0ss192301
    Nov 10 at 10:52












  • Try adding <uses-permission android:name="android.permission.INTERNET" /> As far as I'm aware the merged manifest should already have that, but I could be wrong and this could be causing your problem.
    – daedsidog
    Nov 10 at 10:53












  • I added it before <application ... >and still nothing
    – b0ss192301
    Nov 10 at 10:56










  • Does the console say anything when you try to load the ads?
    – daedsidog
    Nov 10 at 10:57















up vote
1
down vote

favorite












I don't get what I'm doing wrong, I wanted to show a banner on the bottom but not even the test ads show up. I followed their tutorial and my app looks like this:




xml with the ad (it does show up on the preview)




<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/infoPageBackgroundColor"
android:orientation="vertical"
android:paddingTop="8dp"
tools:context=".AppInfoActivity">

...

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:adSize="SMART_BANNER"
app:adUnitId="@string/banner_id"/>





Metadata in AndroidManifest




<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/app_id"/>



Project gradle.build




buildscript {

repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}

}
dependencies {
...
}
}



App gradle.build




dependencies {
...
}



Entry Activity




import com.google.android.gms.ads.MobileAds;


public class EntryActivity extends BaseActivity {
private View progressBar;
private LoadListAsyncTask loadListAsyncTask;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
...

MobileAds.initialize(this, "@string/app_id");
}



Java file




...

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

...


public class StickerPackListActivity extends BaseActivity {
...

private AdView mAdView;

@Override
protected void onCreate(Bundle savedInstanceState) {
...

mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
...


I'm using the banner test ID to try it and it only shows up in the xml editor. Any idea of why? Even if I try my ID it deosn't work. Sorry for not being able to explain much more as it's just like this. Did I forget something?










share|improve this question
























  • What permissions do you have included in the manifest? Are you also getting any errors at all about this in the console? Where exactly are you initialising the SDK?
    – daedsidog
    Nov 10 at 10:50












  • none, what am I supposed to add? I'm initialising it in an entry activity that sets up the app but I could change it somewhere else
    – b0ss192301
    Nov 10 at 10:52












  • Try adding <uses-permission android:name="android.permission.INTERNET" /> As far as I'm aware the merged manifest should already have that, but I could be wrong and this could be causing your problem.
    – daedsidog
    Nov 10 at 10:53












  • I added it before <application ... >and still nothing
    – b0ss192301
    Nov 10 at 10:56










  • Does the console say anything when you try to load the ads?
    – daedsidog
    Nov 10 at 10:57













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I don't get what I'm doing wrong, I wanted to show a banner on the bottom but not even the test ads show up. I followed their tutorial and my app looks like this:




xml with the ad (it does show up on the preview)




<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/infoPageBackgroundColor"
android:orientation="vertical"
android:paddingTop="8dp"
tools:context=".AppInfoActivity">

...

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:adSize="SMART_BANNER"
app:adUnitId="@string/banner_id"/>





Metadata in AndroidManifest




<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/app_id"/>



Project gradle.build




buildscript {

repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}

}
dependencies {
...
}
}



App gradle.build




dependencies {
...
}



Entry Activity




import com.google.android.gms.ads.MobileAds;


public class EntryActivity extends BaseActivity {
private View progressBar;
private LoadListAsyncTask loadListAsyncTask;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
...

MobileAds.initialize(this, "@string/app_id");
}



Java file




...

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

...


public class StickerPackListActivity extends BaseActivity {
...

private AdView mAdView;

@Override
protected void onCreate(Bundle savedInstanceState) {
...

mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
...


I'm using the banner test ID to try it and it only shows up in the xml editor. Any idea of why? Even if I try my ID it deosn't work. Sorry for not being able to explain much more as it's just like this. Did I forget something?










share|improve this question















I don't get what I'm doing wrong, I wanted to show a banner on the bottom but not even the test ads show up. I followed their tutorial and my app looks like this:




xml with the ad (it does show up on the preview)




<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/infoPageBackgroundColor"
android:orientation="vertical"
android:paddingTop="8dp"
tools:context=".AppInfoActivity">

...

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:adSize="SMART_BANNER"
app:adUnitId="@string/banner_id"/>





Metadata in AndroidManifest




<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/app_id"/>



Project gradle.build




buildscript {

repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}

}
dependencies {
...
}
}



App gradle.build




dependencies {
...
}



Entry Activity




import com.google.android.gms.ads.MobileAds;


public class EntryActivity extends BaseActivity {
private View progressBar;
private LoadListAsyncTask loadListAsyncTask;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
...

MobileAds.initialize(this, "@string/app_id");
}



Java file




...

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

...


public class StickerPackListActivity extends BaseActivity {
...

private AdView mAdView;

@Override
protected void onCreate(Bundle savedInstanceState) {
...

mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
...


I'm using the banner test ID to try it and it only shows up in the xml editor. Any idea of why? Even if I try my ID it deosn't work. Sorry for not being able to explain much more as it's just like this. Did I forget something?







android admob






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 10:48

























asked Nov 10 at 10:26









b0ss192301

296




296












  • What permissions do you have included in the manifest? Are you also getting any errors at all about this in the console? Where exactly are you initialising the SDK?
    – daedsidog
    Nov 10 at 10:50












  • none, what am I supposed to add? I'm initialising it in an entry activity that sets up the app but I could change it somewhere else
    – b0ss192301
    Nov 10 at 10:52












  • Try adding <uses-permission android:name="android.permission.INTERNET" /> As far as I'm aware the merged manifest should already have that, but I could be wrong and this could be causing your problem.
    – daedsidog
    Nov 10 at 10:53












  • I added it before <application ... >and still nothing
    – b0ss192301
    Nov 10 at 10:56










  • Does the console say anything when you try to load the ads?
    – daedsidog
    Nov 10 at 10:57


















  • What permissions do you have included in the manifest? Are you also getting any errors at all about this in the console? Where exactly are you initialising the SDK?
    – daedsidog
    Nov 10 at 10:50












  • none, what am I supposed to add? I'm initialising it in an entry activity that sets up the app but I could change it somewhere else
    – b0ss192301
    Nov 10 at 10:52












  • Try adding <uses-permission android:name="android.permission.INTERNET" /> As far as I'm aware the merged manifest should already have that, but I could be wrong and this could be causing your problem.
    – daedsidog
    Nov 10 at 10:53












  • I added it before <application ... >and still nothing
    – b0ss192301
    Nov 10 at 10:56










  • Does the console say anything when you try to load the ads?
    – daedsidog
    Nov 10 at 10:57
















What permissions do you have included in the manifest? Are you also getting any errors at all about this in the console? Where exactly are you initialising the SDK?
– daedsidog
Nov 10 at 10:50






What permissions do you have included in the manifest? Are you also getting any errors at all about this in the console? Where exactly are you initialising the SDK?
– daedsidog
Nov 10 at 10:50














none, what am I supposed to add? I'm initialising it in an entry activity that sets up the app but I could change it somewhere else
– b0ss192301
Nov 10 at 10:52






none, what am I supposed to add? I'm initialising it in an entry activity that sets up the app but I could change it somewhere else
– b0ss192301
Nov 10 at 10:52














Try adding <uses-permission android:name="android.permission.INTERNET" /> As far as I'm aware the merged manifest should already have that, but I could be wrong and this could be causing your problem.
– daedsidog
Nov 10 at 10:53






Try adding <uses-permission android:name="android.permission.INTERNET" /> As far as I'm aware the merged manifest should already have that, but I could be wrong and this could be causing your problem.
– daedsidog
Nov 10 at 10:53














I added it before <application ... >and still nothing
– b0ss192301
Nov 10 at 10:56




I added it before <application ... >and still nothing
– b0ss192301
Nov 10 at 10:56












Does the console say anything when you try to load the ads?
– daedsidog
Nov 10 at 10:57




Does the console say anything when you try to load the ads?
– daedsidog
Nov 10 at 10:57












2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










You forgot to initialise AdMob:



@Override
protected void onCreate(Bundle savedInstanceState) {
...
MobileAds.initialize(this, "BANNER_ID_HERE");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
...
}


https://developers.google.com/admob/android/banner



Recently created AdMob banners sometime fail to load with error code 2 when tested on physical devices. You should always test them on an emulator to ensure everything has been done correctly, seeing as there is nothing wrong with your code.






share|improve this answer























  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46


















up vote
0
down vote













You need to initialize the Ads SDK:



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ...
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
}


https://firebase.google.com/docs/admob/android/quick-start



Also make sure that your app id and banner id are correct:



https://support.google.com/admob/answer/7356431?hl=en






share|improve this answer





















  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238018%2fadmob-ads-not-showing-not-even-test-ads%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










You forgot to initialise AdMob:



@Override
protected void onCreate(Bundle savedInstanceState) {
...
MobileAds.initialize(this, "BANNER_ID_HERE");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
...
}


https://developers.google.com/admob/android/banner



Recently created AdMob banners sometime fail to load with error code 2 when tested on physical devices. You should always test them on an emulator to ensure everything has been done correctly, seeing as there is nothing wrong with your code.






share|improve this answer























  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46















up vote
1
down vote



accepted










You forgot to initialise AdMob:



@Override
protected void onCreate(Bundle savedInstanceState) {
...
MobileAds.initialize(this, "BANNER_ID_HERE");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
...
}


https://developers.google.com/admob/android/banner



Recently created AdMob banners sometime fail to load with error code 2 when tested on physical devices. You should always test them on an emulator to ensure everything has been done correctly, seeing as there is nothing wrong with your code.






share|improve this answer























  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46













up vote
1
down vote



accepted







up vote
1
down vote



accepted






You forgot to initialise AdMob:



@Override
protected void onCreate(Bundle savedInstanceState) {
...
MobileAds.initialize(this, "BANNER_ID_HERE");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
...
}


https://developers.google.com/admob/android/banner



Recently created AdMob banners sometime fail to load with error code 2 when tested on physical devices. You should always test them on an emulator to ensure everything has been done correctly, seeing as there is nothing wrong with your code.






share|improve this answer














You forgot to initialise AdMob:



@Override
protected void onCreate(Bundle savedInstanceState) {
...
MobileAds.initialize(this, "BANNER_ID_HERE");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
...
}


https://developers.google.com/admob/android/banner



Recently created AdMob banners sometime fail to load with error code 2 when tested on physical devices. You should always test them on an emulator to ensure everything has been done correctly, seeing as there is nothing wrong with your code.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 10 at 13:09

























answered Nov 10 at 10:45









daedsidog

977724




977724












  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46


















  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46
















Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
– b0ss192301
Nov 10 at 10:46




Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
– b0ss192301
Nov 10 at 10:46












up vote
0
down vote













You need to initialize the Ads SDK:



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ...
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
}


https://firebase.google.com/docs/admob/android/quick-start



Also make sure that your app id and banner id are correct:



https://support.google.com/admob/answer/7356431?hl=en






share|improve this answer





















  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46















up vote
0
down vote













You need to initialize the Ads SDK:



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ...
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
}


https://firebase.google.com/docs/admob/android/quick-start



Also make sure that your app id and banner id are correct:



https://support.google.com/admob/answer/7356431?hl=en






share|improve this answer





















  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46













up vote
0
down vote










up vote
0
down vote









You need to initialize the Ads SDK:



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ...
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
}


https://firebase.google.com/docs/admob/android/quick-start



Also make sure that your app id and banner id are correct:



https://support.google.com/admob/answer/7356431?hl=en






share|improve this answer












You need to initialize the Ads SDK:



@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ...
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
}


https://firebase.google.com/docs/admob/android/quick-start



Also make sure that your app id and banner id are correct:



https://support.google.com/admob/answer/7356431?hl=en







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 10:44









Javier Delgado

8821719




8821719












  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46


















  • Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
    – b0ss192301
    Nov 10 at 10:46
















Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
– b0ss192301
Nov 10 at 10:46




Sorry I forgot to add that I already initialized it too with MobileAds.initialize(this, "ID"); in my entry activity
– b0ss192301
Nov 10 at 10:46


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238018%2fadmob-ads-not-showing-not-even-test-ads%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff