Cannot display AdMob banners, Received error HTTP

2019-02-27 04:35发布

问题:

Whatever I do I cannot display the banners from Admob, I tested on two Android different devices and here is what I get:

First device:

I/Ads     ( 8161): Starting ad request.
I/Ads     ( 8161): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
I/Ads     ( 1006): CsiReporterFactory: CSI is not enabled. No CSI reporter created.
W/Ads     ( 1006): JS: The page at about:blank displayed insecure content from gmsg://mobileads.google.com/loadAdURL?drt_include=0&request_id=............
W/Ads     ( 1006):  (null:1)
W/Web Console( 1006): The page at about:blank displayed insecure content from gmsg://mobileads.google.com/loadAdURL?drt_include=0&request_id=............
W/Ads     ( 1006): JS: The page at about:blank displayed insecure content from gmsg://mobileads.google.com/loadAdURL?drt_include=0&request_id=............
W/Ads     ( 1006):  (null:1)
W/Web Console( 1006): The page at about:blank displayed insecure content from gmsg://mobileads.google.com/loadAdURL?drt_include=0&request_id=............
W/Ads     ( 1006): JS: The page at https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40.html displayed insecure content from file:///android_asset/webkit/android-weberror.png.
W/Ads     ( 1006):  (null:1)
W/Ads     ( 1006): Received error HTTP response code: 400
W/Ads     ( 8161): There was a problem getting an ad response. ErrorCode: 0
W/Ads     ( 8161): Failed to load ad: 0

Note: here neither onAdLoaded( ) nor onAdFailedToLoad( ) is getting called

Second device:

I/Ads     ( 1165): CsiReporterFactory: CSI is not enabled. No CSI reporter created.
I/Ads     ( 1165): Starting ad request.
I/Ads     ( 1165): Use AdRequest.Builder.addTestDevice("XXXXXXXXXXXXXXXXXXXXXXXXXX") to get test ads on this device.     
I/Ads     ( 1165): CsiReporterFactory: CSI is not enabled. No CSI reporter created.
W/Ads     ( 1165): There was a problem getting an ad response. ErrorCode: 2
I/Ads     ( 1165): Scheduling ad refresh 60000 milliseconds from now.
W/Ads     ( 1165): Failed to load ad: 2

My code:

protected void onCreate( Bundle icicle )
{
 super.onCreate( icicle );

m_glView = initOpenGLView( ); 

 m_adMobView = new AdView( this );
 m_adMobView.setAdSize( AdSize.SMART_BANNER );
 m_adMobView.setAdUnitId( "XXXXXXXXXXXXXXXXXX" );      <----I just replaced the ID with XXX for this example
 m_adMobView.setAdListener( new AdListener( )
  {
   public void onAdLoaded( ) 
   { 
    egNative.LogMessage( "ADMob::onAdLoaded" );
   };
   public void onAdFailedToLoad( )
   {
    egNative.LogMessage( "ADMob::onAdFailedToLoad" );
   }
  }  );

 FrameLayout layout = new FrameLayout( getApplicationContext( ) );
 layout.addView( m_glView );

 int gravity = android.view.Gravity.CENTER_HORIZONTAL | android.view.Gravity.TOP;
 FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT , 
            FrameLayout.LayoutParams.WRAP_CONTENT ,  gravity );
  layout.addView( m_adMobView , params );
setContentView( layout );
}

@Override protected void onStart( )
 {
  super.onStart( );
  AdRequest.Builder ad_builder = new AdRequest.Builder( );
  m_adMobView.loadAd( ad_builder.build( ) );
 }

I am running the latest version of Google Play services. Also have double checked the Ad unit IDs and they're fine. Not getting any positive results with test Ad unit IDs too. Can you guys post any hints eventually? Thank you in advance.

回答1:

  1. Make sure you have copied the latest google-services.json from firebase console to your project root directory.
  2. For native ads, DON'T simply copy past the example code given in Native Ads Express guide. Analyse the ad space available in your all device supporting screens. Ex., if you have only 300 dp ad space that actually an ad can accommodate, then you should not request the ad size more than 300dp in adSize attribute.
  3. Check for your device's ad space available(also check for padding and margin) then compare the ad size table above and choose the right value that suites. ex., if your device has 300dp width then change adSize value as 300x150 to get ads and also adjust these values for better ad presentation.
  4. If your ad space falls in medium category, then create a right ad unit in admob. You can review the ad presentation in admob preview pane with the space you allotted in your code.
  5. If you created the AdUnit id newly in Admob, the admob server is taking bit time to review & approve your native ads template. So wait for some time and try again (approx 1-2 hrs). Meanwhile make sure that your code complies with all the above 4 points.


回答2:

Your package is blocked by Google AdMob. If you received a email like this:

Hello,

This email is to alert you that one of your applications is not currently in compliance with our AdMob program policies and as a result, ad serving has been disabled to your application.

Issue ID#: 33943***

Ad serving has been disabled to: APPNAME (com.example.pack)

Action required: Check all other remaining applications in your account for compliance.

Current account status: Active

Violation explanation

GOOGLE PLAY REMOVAL: AdMob publishers are not permitted to abuse or promote the abuse of any Google product, such as Google Play, YouTube, or Blogger. This includes circumventing, or providing the means to circumvent, the policies or terms of these or other Google products, such as by allowing users to download YouTube videos.

If your app is removed by Google Play policy enforcement, please contact Google Play about an app removal here. If Google Play reinstates your app, please submit an appeal to our team.

Action required: Check account for compliance

While ad serving has been disabled to the above app, your AdMob account remains active. We suggest that you take the time to review the rest of your applications to ensure that they’re in compliance with our policies, and to monitor your apps accordingly to reduce the likelihood of future policy emails from us. Additionally, please note that our team reserves the right to disable accounts at any time if we continue to see violations occurring.

Appeals

If you wish to appeal this disabling then you can do so by using our appeal form.

Thank you for your cooperation.

Sincerely,

The Google AdMob Team

So now you need to change your package of your app. on eclipse it is package="com.example" in AndroidManifest.xml file

or

on AndroidStudio applicationId "com.example" in build.gradle file



回答3:

I had same issue. It started work for me after I had updated my Billing and Payments details in AdMob Account.



回答4:

Uninstalled the google play services update and it started working.



回答5:

I switched from Google Play Services Ads to Firebase Ads and cleaning the project after restarting Android Studio worked for me.



标签: android admob