how to use the physical device to test ads [Android] - android

After the change of the version of google services ads, the addTestDevice option no longer appears, how can I see bonus videos on a physical device?
AdRequest adRequest = new AdRequest.Builder().build();
RewardedAd.load(this, "ca-app-pub-3940256099942544/5224354917",
adRequest, new RewardedAdLoadCallback() {
#Override
public void onAdFailedToLoad(#NonNull LoadAdError loadAdError) {
// Handle the error.
// Log.d(TAG, loadAdError.getMessage());
mRewardedAd = null;
}
#Override
public void onAdLoaded(#NonNull RewardedAd rewardedAd) {
mRewardedAd = rewardedAd;
//Log.d(TAG, "Ad was loaded.");
}
});

You can follow steps here
Add a test device To make changes to a test device, such as enabling
or changing ad inspector gestures, you’ll need to remove the test
device and set it up again. Sign in to your AdMob account at
https://apps.admob.com.
Click Settings in the sidebar.
Click the Test devices tab.
Click Add test device.
Select the platform of your device.
Enter a device name. Consider using a name that will help you quickly
identify your devices in your AdMob account.
Note: The device name will be visible to anyone who has access to your
AdMob account.
Enter your Advertising ID/IDFA. Learn how to find your advertising
ID/IDFA.
Select a gesture to use to activate ad inspector:
None. If you select none, you can still activate ad inspector with an
API call. Learn more.
Shake
Flick twice
Click Done.

Related

Inmobi.com "ad request successful but no ad served"

When I try to load an interstitial with inmobi.com and most of the times I get the error "ad request successful but no ad served". Why is this happening? Any solution for this? It works well with testing ads when set to "Test mode" in the website. Will this be because inmobi has not enough providers to display ads at that moment?
I asked Inmobi support page but they don't answer. I am starting to regret moving from admob to inmobi.
This is the code I use:
JSONObject consentObject = new JSONObject();
try {
consentObject.put(InMobiSdk.IM_GDPR_CONSENT_AVAILABLE, true); // Provide correct consent value to sdk which is obtained by User
consentObject.put("gdpr", "1"); // Provide 0 if GDPR is not applicable and 1 if applicable
//consentObject.put(InMobiSdk.IM_GDPR_CONSENT_IAB, “<<consent in IAB format>>”); // Provide user consent in IAB format
} catch (JSONException e) {
}
InMobiSdk.init(this, "My InMobi Account ID here", consentObject);
long MyPlacementID = 1234566789L; //My Placement ID here as long
mInterstitialAd = new InMobiInterstitial(this, MyPlacementID, new InterstitialAdEventListener() {
#Override
public void onAdLoadSucceeded(InMobiInterstitial inMobiInterstitial) {
super.onAdLoadSucceeded(inMobiInterstitial);
if (inMobiInterstitial.isReady()) {
mInterstitialAd.show();
}
#Override
public void onAdLoadFailed(InMobiInterstitial inMobiInterstitial, InMobiAdRequestStatus inMobiAdRequestStatus) {
sError = inMobiAdRequestStatus.getMessage();
Here I get error: "ad request successful but no ad served"
}
I emailed the support team and they answered that is shown if they don't have any ad to be displayed (maybe for my location or for my time). So, it is just that they run out of ads to be displayed. If I try it many many times then I may get one ad. So it is a server problem. Not enough clients to pay for ads. It is a pity.
I was having the same issue.I tried different ways to get the test ads.But everything was in vein.Then i went through their documentation and found that we need to set up a layout for ad placement.There is an option to customize that.Click on save and then add your device id in the testing devices section, you will see test ads coming up.I found this one from an article where it said "If you set banner sizes different from those provided by default, the SDK will refuse to load data and will issue a corresponding message to the log:
[InMobi]: Failed to fetch ad for placement id: 201901231449, reason phrase available in onAdLoadFailed callback.
And the message “Ad request successful but no ad served” with the code “NO_FILL” appears in the listener's method. Hence our expert advice: always redefine the listener's methods which are responsible for errors. Acting such a way, you'll avoid many difficulties later."
https://agilie.com/en/blog/how-to-integrate-inmobi-sdk-to-start-monetizing-your-android-app
Contradicting answer to #Ton's answer.
All the ad servers work in the following manner. Advertisers pay for ads with specific targetted audiences. So whenever you ask an ad network to provide an ad it actually checks if they have an ad for which targeting is matched with the current user (for ex. area, gender, age as and when available). If they don't have any ad which can be shown to the current user then they will fire NO_FILL.
Also, specific to InMobi, they don't provide many ads on emulators so try on a physical device to get ads.

facebook ad cant' load in sdk version 5.+

i have create facebook ad demo app, but can't load any ad(Interstitial ,Native ,Banner) in any version sdk.
if i using sdk version 5.3.0 then facebook ad return error.
Error: New bundles must use latest available Audience Network SDK.
if i using sdk version 5.5.0,5.6.0 then facebook ad return error.
Error: No fill
i also tried live ad id(264476213973610_264482430639655) and testing ad id (YOUR_PLACEMENT_ID) but doesn't work
AudienceNetworkAds.initialize(this);
final InterstitialAd interstitialAd = new InterstitialAd(MainActivity.this, "YOUR_PLACEMENT_ID");
AdSettings.addTestDevice("6f2e675e-05b0-46d8-b3d6-032ef6a25fdb");
interstitialAd.destroy();
interstitialAd.setAdListener(new InterstitialAdListener() {
#Override
public void onInterstitialDisplayed(Ad ad) {
Log.e(TAG, "Interstitial ad displayed.");
}
#Override
public void onInterstitialDismissed(Ad ad) {
Log.e(TAG, "Interstitial ad dismissed.");
}
#Override
public void onError(Ad ad, AdError adError) {
Toast.makeText(MainActivity.this, "Error: " + adError.getErrorMessage(), Toast.LENGTH_LONG).show();
}
#Override
public void onAdLoaded(Ad ad) {
Toast.makeText(MainActivity.this, "Loaded: " + ad.getPlacementId(), Toast.LENGTH_LONG).show();
interstitialAd.show();
}
#Override
public void onAdClicked(Ad ad) {
Log.d(TAG, "Interstitial ad clicked!");
}
#Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "Interstitial ad impression logged!");
}
});
interstitialAd.loadAd();
I had faced a similar issue. So I'll explain how I solved it.
To test properly on your device, you need to follow some other steps too other than you mentioned in the question.
STEPS:
Properly follow the interstitial, banner, etc. documentation to integrate ads
Download the official Facebook app (which is required to get test ads) and log in using either tester's account or Admin's account of the Audience Network. FB doesn't return ads if it doesn't find its official app on the device because it crawls the data of the account to provide the relevant ads to the user
Add test device to get test ads (or live ads for testing which doesn't give you revenue). To add a device:
i) Login to your Audience Network account
ii) Go to Monetization Manager > Integration > Testing
iii) Add test device using Android's AAID or iOS's IDFA. You can check other SO's threads to find AAID or IDFA of the device, in case you don't know.
iv) You can test it in the device now and you must be getting ads. If still there are no ads, select Use real advertiser content option there itself. Now to test different type of ads like HD Video, Simple Image or such; Click Select Ad Type on the same screen
NOTE: Remember to check the article on FAN's ad Caching in Android 9+ because HD Video or any type of video ads won't show on Android 9+ and you might get a blank screen blocking all the functionalities of your app.
use sdk version com.facebook.android:audience-network-sdk:5.11.0

Admob live ads not showing in my application,while testing ads showing

Admob Live ads are not showing, while testing ads are showing. Live ads are not showing at all, I don't know what i am missing.
Here is code.
String.java XML
<!-- Insert Id admob -->
<string name="BannerAd_unit_id">cca-app-pub-1154915214031679/2100011458</string>
<string name="InterstitialAd_unit_id">ca-app-pub-1154915214031679/9049914448</string>
MainGame.Java Class
this.BANNER_AD_UNIT_ID = getResources().getString(R.string.BannerAd_unit_id);
showBanner();
screen java.class
public void showBanner() {
//banner ad
if (BANNER_AD_UNIT_ID.length() > 0) {
// Create an ad.
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(BANNER_AD_UNIT_ID);
//make ad visible on bottom of screen
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params1.addRule(RelativeLayout.CENTER_HORIZONTAL);
adView.setLayoutParams(params1);
layout.addView(adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
//.addTestDevice("C01834A0B4A8FA4C03A0E09605F43819")//GalaxyS4*/
.build();
// Start loading the ad in the background.
adView.loadAd(adRequest);
}
}
If I Remove comment ".addTestDevice" Then testing ads are showing, if I comment it then live ads not showing. I don't know what is going on, any help will be appreciated.
If you're not receiving real ads, but are receiving 'test ads' then the implementation should be ok.
If you just created the ad account, it takes a few hours until real ads will appear and sometimes there might be no adds available to show.
Set an adListener to your adView and see what you're getting back. It might be a ERROR_CODE_NO_FILL or it might give you other hints to solve the problem.
Make sure you have updated AdMob with your payment details (go to Payments Section for that).
Check your AdMob dashboard to see the status of your ads to check if they are active.
Verify you used the correct Ad Unit Id.
After you update your info, it may take up to 24 hours to verify your information. After verification, they will enable your ad serving. You will get an email notification saying your ads are now being served.
If the test ads are working fine then your implementation is correct, but there is an option of "Payment" in the admob account which you need to fill. After filling up that form you will receive an email regarding the confirmation of payment details and message indicating that whether your information was accepted by the admob team or not if yes then your live ads will be showing up. But keep in mind that for the first few time the ad won't show up. it takes time to appear after the approval as well.
Here is the code snippet for the error code to find what is going wrong
mAdView = (com.google.android.gms.ads.AdView) findViewById(R.id.adView);
mAdView.setAdListener(new com.google.android.gms.ads.AdListener() {
#Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
Toast.makeText(HomeActivity.this, "onAdLoaded", Toast.LENGTH_SHORT).show();
}
#Override
public void onAdFailedToLoad(int errorCode) {
if(errorCode==AdRequest.ERROR_CODE_INTERNAL_ERROR)
Toast.makeText(HomeActivity.this, "onAdFailedToLoad", Toast.LENGTH_SHORT).show();
// Code to be executed when an ad request fails.
}
#Override
public void onAdOpened() {
Toast.makeText(HomeActivity.this, "onAdOpened", Toast.LENGTH_SHORT).show();
}
#Override
public void onAdLeftApplication() {
Toast.makeText(HomeActivity.this, "onAdLeftApplication", Toast.LENGTH_SHORT).show();
}
#Override
public void onAdClosed() {
Toast.makeText(HomeActivity.this, "onAdClosed", Toast.LENGTH_SHORT).show();
}
})
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Get the error code:
ERROR_CODE_INTERNAL_ERROR - Something happened internally; for instance, an invalid response was received from the ad server.
ERROR_CODE_INVALID_REQUEST - The ad request was invalid; for instance, the ad unit ID was incorrect.
ERROR_CODE_NETWORK_ERROR - The ad request was unsuccessful due to network connectivity.
ERROR_CODE_NO_FILL - The ad request was successful, but no ad was returned due to lack of ad inventory.

Admob Not showing ads on real devices only showing on Test devices only

private void showInterstitialadd() {
mInterstitialAd = new InterstitialAd(MainActivity.this);
// set the ad unit ID
mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));
AdRequest adRequest = new AdRequest.Builder()
.build();
// Load ads into Interstitial Ads
mInterstitialAd.loadAd(adRequest);
mInterstitialAd.setAdListener(new AdListener() {
public void onAdLoaded() {
showInterstitial();
}
});
}
private void showInterstitial() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
}
}
I am using the above function for showing Ads....and its working absolutely fine on my test device but when I remove that .addTestdevice().....and run on any other devices it does not shows up....
There may be no issue in your code but AdMob doesn't show ads on real device quickly. You have to wait for few days. Before that, you have to enter some details like address and payment account detail in your AdMob account.
Don't worry they guide via email.
After you enter details, wait for few days, you will be notified in AdMob account that ads are showing.
In my case, it takes 2 days and, only Banner and Interstitial ads were activated at that time and video ads still do not get loaded.
So if ads are showing on test device then it will also be showing in the real device. The only thing you have to do is complete AdMob account setup and wait.
Also, don't forget to remove .addTestdevice() code before checking on real device.

onFailedToRecieveAd(Invalid Ad Request) message with AdMob

I've been trying to get AdMob to work for some time on my app. I keep getting onFailedToRecieveAd(Invalid Ad Request) message in the log. I've paired down my test application to this:
AdView adView;
LinearLayout ll;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
adView = new AdView(this, AdSize.BANNER, "pub-2...............");//inserted my 16 digit pub id here
adView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(adView);
setContentView(ll);
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice("3...............");// 16 digits, tried other strings as
// follows:
//for addTestDevice I've tried several numbers, including the 16 digit device
// number given me by my "device id" application, the "0123456789ABCDEF" device number
// given by my console and device windows, the "CECE.........................." 32 digit
// device number my logcat file told me to use in a logcat message,
// "AdRequest.TEST_EMULATOR"
// which an admob example in the docs said to use, "9774d56d682e549c" which another
// admob docs example said to use.
adView.loadAd(adRequest);
I've also tried adView.loadAd(new AdRequest()); using no device id as in another one of the google admob example apps.
nothing has worked to show anything, it's not even creating space for the ad, just the onFailedToRecieveAd(Invalid Ad Request) message in the logcat
I've also included the necessary permissions and "com.google.ads.AdActivity" in the manifest.
Wow, after days of frustration and posts to various forums I've found the answer.
You have to go to your account on the Admob website to set up your specific app for the admob ads and get a new longer publisher number. My publisher number only started with 'pub-......' where my new number is longer and starts with 'ca-app-pub-.......'. I was curious about this from the start when I saw the 'ca-app-pub' preface in an example banner ap.
Nowhere on the Google Admob "Google Mobile Ads SDK" development site in the "banner ads 1" instructions (https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals?hl=en_US#android) does it mention having to go back to your admob account to set up your specific app for ads and get a new publisher number.
The stupid mistakes are the hardest to fix.
Be carefull with the id, there are 2 codes: the editor number (like this: pub-xxxxxxxxxxxxxxxx) and the other is the banner id (like this: ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx) (this one you need to use)
You need to use the last one, if you use the first doesnt work:)
It is not unusual to get a failed to receive ad. This is a normal message essentially saying that there are no ads to serve for your app at this point in time.
It means that your Admob integration is working, you are getting a response back from the server. As your app sends more requests it will be more likely to receive ad impressions.
Have you tried requesting an ad without setting the test device ID?
adView.loadAd(new AdRequest());
Try adding the following lines of code to get more info about the failure:
// Set AdListener
adView.setAdListener(new AdListener() {
#Override
public void onFailedToReceiveAd(Ad ad, ErrorCode error) {
System.err.println("Ad failed: " + ad.toString() + error.toString());
}
#Override
public void onReceiveAd(Ad ad) {
System.out.println("Ad received: " + ad.toString());
}
});

Categories

Resources