So, I tried inserting an ad in my app. The test ad is visible on emulator but not on the real device. This question may seem like duplicate but it isn't. I have looked many questions regarding that but they aren't relevant to me. I seem to get everything right on emulator but not on real device. Then I debugged the app on my moto G4 and still no ad.
On my activity:
MobileAds.initialize(this, "ca-app-pub-4408797825766729~9067984003");
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
On the layout xml:
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
ads:adSize="LARGE_BANNER"
ads:adUnitId="ca-app-pub-4408797825766729/5546529636" />
other than this I didn't code anything related to ads.
If you Have created/added new app on admob it will take time to show ads on your app.
and make sure you have this permission
<uses-permission android:name="android.permission.INTERNET" />
Related
Admob is not working correctly when putting my banner id, but it's working when adding debug banner id for testing, any help ?
XML code
<com.google.android.gms.ads.AdView
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="#string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
Java code
MobileAds.initialize(this, "ca-app-pub-****************");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
and I have these permission in manifist
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
This is the banner ad that I have is it right ?
If the debug ads shows up, then your implementation is correct. Sometimes ads don't show up until they get released (not always true). But yeah it does take a while for google to find the right ads for your app. Be patient
The problem was because I wasn't setting my payment address in admob.
I add admob for my app as guide:
https://firebase.google.com/docs/admob/android/quick-start
and
https://www.youtube.com/watch?v=OLLLRUPICcc&list=PLOU2XLYxmsIKX0pUJV3uqp6N3NeHwHh0c&index=1&spfreload=5
But admob is only view:
Nice job! You're displaying a 320x50 test ad from admob
It does NOT change other ads. Please help me.
Code as below:
In activity at onCreate:
MobileAds.initialize(this, "ca-app-pub-9518053516260440/6844465750");
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
in xml:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
Acording to the Quickstart
If you haven't created an AdMob account and registered an app yet,
there's no better time than now. If you're just experimenting with the
SDK in a Hello World app, though, you can use this App ID to call the
initialize method: ca-app-pub-3940256099942544~3347511713.
You are using testing appID. To make it work you need to create your own account. Than create application and use your own application ID. This will let you customize what ads should show and it will show actual ads. But for testing you should use this AppID, because you should not click on your own ads.
Fix your appID in xml. But even then it takes some time to actualy start working. It might take about day to start showing real ads.
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"
/>
I have a problem with my Android App which I'm trying to add ads for, the weird thing is that the ad loads perfectly on the first activity, but none of the others. I've followed the instructions on https://developers.google.com/admob/android/existing-app, but to no avail it still only works with the first activity. I have a different Ad Unit ID for each activity that I have ads on as well, and have copy-pasted them from the website to avoid mistakes, and have removed all whitespace.
The response I get is:
There was a problem getting an ad response. ErrorCode: 0
Failed to load ad: 0
I've done research on why I'd get this response from AdMob, and I've tried the solutions I have found, they are to add the correct version (and check for updates) of the Google Play Services to my build.gradle file, to add the version to my manifest file, I am running it on the stock rom that came with a real phone (LG G4 running Lollipop) I even tried on a different phone which was also running stock Android to get the same result.
The way I load the ads onto my page is with this code:
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
This is the same on every activity with ads on it.
This is a snippet of my Manifest file:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Finally, this is the ad snippet of my layout file, which is also the same in all of my layouts:
<com.google.android.gms.ads.AdView
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="#string/banner_home">
</com.google.android.gms.ads.AdView>
I have a string resource for each different activity Ad Unit ID.
It just started working, I changed nothing. Maybe there was a problem building it before? Who knows, thanks for all the help though guys.
AdView adView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
adView.loadAd(adRequest);
Whenever you load Admob banner ad this gives 0 error.This is just because you have not signed it.you must load and show Test admob Banner ad.if test ad is servering perfectly then you will get right ad in signed apk.0 error may be just because you have not signed apk
did you added this line in your manifest file?
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
or try like this
Open your adMob account and create new sets of keys,and put this keys(banner/interstitial)in your project.this is happens to me once i fixed like this,try this solution. or still issues create new app (just change the name) in adMob and create new keys
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.