开发者

AdMob Response message is null or zero length

So, I've been trying to implement AdMob API's in my app for several days and I've basically copied and pasted the basic sample code provided. It seems to be working, but I keep getting onFailedToReceiveAd(A network error occurred). and Response is null or zero length.

Here is my manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="ragingsoftware.android.AdsTest"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".MainActivity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.google.ads.AdActivity"
          android:configChanges="keyboard|keyboardHidden|orientation"/>

</application>
</manifest>

Here is my main layout xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/LinearLayoutMain">
<TextView  
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello"
/>
<LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:layout_width="match_parent"></LinearLayout>
</LinearLayout&g开发者_开发问答t;

Here is my Activity code:

private void initAds() {
    // Create the adView
    AdView adView = new AdView(this, AdSize.BANNER, "XXXXXXXXXXXXXXX");
    // Lookup your LinearLayout assuming it’s been given
    // the attribute android:id="@+id/mainLayout"
    LinearLayout layout = (LinearLayout)findViewById(R.id.LinearLayoutMain);
    // Add the adView to it
    layout.addView(adView);
    // Initiate a generic request to load it with an ad
    adView.loadAd(new AdRequest());
}

And last, but not least, the logcat:

03-20 00:48:37.569: INFO/Ads(12511): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"msid":"ragingsoftware.android.WiFiScheduler","hl":"en","preqs":0,"u_so":"p","slotname":"a14d83d19c4eaef","js":"afma-sdk-a-v4.0.2","app_name":"4.0.2.android.ragingsoftware.android.WiFiScheduler","isu":"358ABB21689377B8D76F4A16B987E097","u_audio":1,"u_w":320,"format":"320x50_mb","u_sd":1.0,"net":"ed","u_h":480});</script></head><body></body></html>
03-20 00:48:39.059: INFO/Ads(12511): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?msid=ragingsoftware.android.WiFiScheduler&hl=en&preqs=0&u_so=p&slotname=a14d83d19c4eaef&js=afma-sdk-a-v4.0.2&app_name=4.0.2.android.ragingsoftware.android.WiFiScheduler&isu=358ABB21689377B8D76F4A16B987E097&u_audio=1&u_w=320&format=320x50_mb&u_sd=1&net=ed&u_h=480&output=html&region=mobile_app&u_tz=240&ex=1&client_sdk=1", "afmaNotifyDt": "null">
03-20 00:48:42.599: INFO/Ads(12511): AdLoader timed out while getting the HTML.
03-20 00:48:42.599: INFO/Ads(12511): onFailedToReceiveAd(A network error occurred.)
03-20 00:48:42.619: INFO/Ads(12511): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"msid":"ragingsoftware.android.WiFiScheduler","hl":"en","preqs":1,"u_so":"p","slotname":"a14d83d19c4eaef","js":"afma-sdk-a-v4.0.2","app_name":"4.0.2.android.ragingsoftware.android.WiFiScheduler","isu":"358ABB21689377B8D76F4A16B987E097","u_audio":1,"u_w":320,"format":"320x50_mb","u_sd":1.0,"net":"ed","u_h":480});</script></head><body></body></html>
03-20 00:48:43.179: INFO/Ads(12511): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?msid=ragingsoftware.android.WiFiScheduler&hl=en&preqs=1&u_so=p&slotname=a14d83d19c4eaef&js=afma-sdk-a-v4.0.2&app_name=4.0.2.android.ragingsoftware.android.WiFiScheduler&isu=358ABB21689377B8D76F4A16B987E097&u_audio=1&u_w=320&format=320x50_mb&u_sd=1&net=ed&u_h=480&output=html&region=mobile_app&u_tz=240&ex=1&client_sdk=1&askip=1", "afmaNotifyDt": "null">
03-20 00:48:47.630: INFO/Ads(12511): AdLoader timed out while getting the HTML.
03-20 00:48:47.649: INFO/Ads(12511): onFailedToReceiveAd(A network error occurred.)
03-20 00:48:47.869: INFO/Ads(12511): Response message is null or zero length: 
03-20 00:48:48.119: INFO/Ads(12511): Response message is null or zero length: 
03-20 00:50:00.219: INFO/Ads(12511): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"msid":"ragingsoftware.android.WiFiScheduler","hl":"en","preqs":2,"u_so":"p","slotname":"a14d83d19c4eaef","js":"afma-sdk-a-v4.0.2","app_name":"4.0.2.android.ragingsoftware.android.WiFiScheduler","isu":"358ABB21689377B8D76F4A16B987E097","u_audio":1,"u_w":320,"format":"320x50_mb","u_sd":1.0,"net":"ed","u_h":480});</script></head><body></body></html>
03-20 00:50:00.219: INFO/Ads(12511): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"msid":"ragingsoftware.android.WiFiScheduler","hl":"en","preqs":2,"u_so":"p","slotname":"a14d83d19c4eaef","js":"afma-sdk-a-v4.0.2","app_name":"4.0.2.android.ragingsoftware.android.WiFiScheduler","isu":"358ABB21689377B8D76F4A16B987E097","u_audio":1,"u_w":320,"format":"320x50_mb","u_sd":1.0,"net":"ed","u_h":480});</script></head><body></body></html>
03-20 00:50:00.909: INFO/Ads(12511): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?msid=ragingsoftware.android.WiFiScheduler&hl=en&preqs=2&u_so=p&slotname=a14d83d19c4eaef&js=afma-sdk-a-v4.0.2&app_name=4.0.2.android.ragingsoftware.android.WiFiScheduler&isu=358ABB21689377B8D76F4A16B987E097&u_audio=1&u_w=320&format=320x50_mb&u_sd=1&net=ed&u_h=480&output=html&region=mobile_app&u_tz=240&ex=1&client_sdk=1&askip=2", "afmaNotifyDt": "null">
03-20 00:50:00.909: INFO/Ads(12511): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?msid=ragingsoftware.android.WiFiScheduler&hl=en&preqs=2&u_so=p&slotname=a14d83d19c4eaef&js=afma-sdk-a-v4.0.2&app_name=4.0.2.android.ragingsoftware.android.WiFiScheduler&isu=358ABB21689377B8D76F4A16B987E097&u_audio=1&u_w=320&format=320x50_mb&u_sd=1&net=ed&u_h=480&output=html&region=mobile_app&u_tz=240&ex=1&client_sdk=1&askip=2", "afmaNotifyDt": "null">
03-20 00:50:05.248: INFO/Ads(12511): AdLoader timed out while getting the HTML.
03-20 00:50:05.249: INFO/Ads(12511): onFailedToReceiveAd(A network error occurred.)
03-20 00:50:05.248: INFO/Ads(12511): AdLoader timed out while getting the HTML.
03-20 00:50:05.249: INFO/Ads(12511): onFailedToReceiveAd(A network error occurred.)
03-20 00:50:05.509: INFO/Ads(12511): Response message is null or zero length: 

I've been googling for days now and can't find an answer. I'd appreciate any help.


You have to set the test mode to true to show the Test Ad on emulator.

LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
AdView adView = new AdView(this, AdSize.BANNER, " a14e01a2c440ee1");
layout.addView(adView);
AdRequest request = new AdRequest();
**request.setTesting(true);**    
adView.loadAd(request);


At first glance, it seems to me that you are missing in the manifest the application's publisher ID assigned by AdMob. You need to add a meta-data field like this:

<meta-data android:value="ADMOB_ID" android:name="ADMOB_PUBLISHER_ID" />

Where ADMOB_ID is the ID assigned by AdMob.


I'm getting the same error for Android < 2.0, but it works for Android > 2.0. I'm currently testing on the emulator. Admob SDK is supposed to be compatible for Android 1.5, but it looks like it doesn't!


I m new in android, my answer may not help to you but as per my knowledge admob sdk send add request after few time interval so u can try with adwhirl

https://www.adwhirl.com/doc/android/AdWhirlAndroidSDKSetup.html

The AdWhirl for Android SDK maximizes your app’s advertising revenue via trivial integration of up to four mobile ad networks:

1) AdMob 2) Google AdSense for Mobile Applications 3) Millennial Media 4) ZestADZ

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜