首页新闻找找看学习计划

求救:Android中植入google广告为什么不成功?

0
悬赏园豆:100 [待解决问题]

用的是GoogleAdMobAdsSdk-4.0.4.jar,Android SDK 2.2:

AndroidManifest.xml配置如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.hxsd.admobdemo"
  android:versionCode="1"
  android:versionName="1.0">
  <uses-sdk android:minSdkVersion="8" />
<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>
  <meta-data android:value="a14f435ee615be1" android:name="ADMOB_PUBLISHER_ID" />
  <activity android:name="com.google.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation"></activity>
  </application>
</manifest>

MainActivity如下:
package com.hxsd.admobdemo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

public class MainActivity extends Activity {
  AdView adView;
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  adView = new AdView(this, AdSize.BANNER, "a14f435ee615be1");  
  LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);  
  layout.addView(adView);  
  AdRequest request = new AdRequest();
  //request.setTesting(true);
  adView.loadAd(request);  
  }
}

我用真机测试,广告始终显示不出来,Log日志如下:
02-23 10:54:55.926: I/Ads(19540): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":0,"u_sd":1.5,"u_w":540,"slotname":"a14f435ee615be1","msid":"com.hxsd.admobdemo","cap":"m","js":"afma-sdk-a-v4.0.4","isu":"D5D04A7D3B4097D8A22DB36E70415F52","format":"320x50_mb","net":"wi","app_name":"4.0.4.android.com.hxsd.admobdemo","hl":"zh","u_h":960,"u_so":"p","u_audio":1});</script></head><body></body></html>
02-23 10:55:55.925: I/Ads(19540): AdLoader timed out while getting the URL.
02-23 10:55:55.925: I/Ads(19540): onFailedToReceiveAd(A network error occurred.)

跪求高手指点。。。。。。

囧囧囧囧的主页 囧囧囧囧 | 初学一级 | 园豆:100
提问于:2012-02-23 11:15
< >
分享
所有回答(1)
0

请求超时了,你看下网络是否有问题。

还有你这模拟请求看看参数是否足够了。

az235 | 园豆:8283 (大侠五级) | 2012-02-23 12:43

wifi没有问题啊  
参数我是按sdk的例子写的  
呜呜~~~~~

支持(0) 反对(0) 囧囧囧囧 | 园豆:100 (初学一级) | 2012-02-23 14:51

@囧囧囧囧: 你要先看看你能否访问Google ad

支持(0) 反对(0) az235 | 园豆:8283 (大侠五级) | 2012-02-23 14:56
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册