2014-04-29 48 views
0


我的广告无法加载我的加入内容,我不确定这是为什么。如果有人能解决我的问题,我将不胜感激。Android Google服务广告未能加载

adView = new AdView(this); 
    adView.setAdSize(AdSize.SMART_BANNER); 
    adView.setAdUnitId(AD_UNIT_ID); 
    FrameLayout layout = new FrameLayout(this); 
    AdRequest adRequest = new AdRequest.Builder() 
     .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
     .build(); 
    adView.loadAd(adRequest); 
    layout.addView(adView); 

logcat的截图: http://puu.sh/8sxZN.png

舱单件:

 <meta-data android:name="com.google.android.gms.version" 
      android:value="@integer/google_play_services_version"/> 

<activity android:name="com.google.android.gms.ads.AdActivity" 
     android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/> 

整个上创建:

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    a = getSharedPreferences("userdata",0); 
    b = a.edit(); 
    setContentView(R.layout.activity_main); 
    adView = new AdView(this); 
    adView.setAdSize(AdSize.BANNER); 
    adView.setAdUnitId(AD_UNIT_ID); 
    FrameLayout layout = new FrameLayout(this); 
    AdRequest adRequest = new AdRequest.Builder() 
     .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) 
     .addTestDevice("065294C80051124D2AB59139999F3202") 
     .build(); 
    adView.loadAd(adRequest); 
    layout.addView(adView); 
    auth = new Authenticate(b, a, d); 
    if (auth.auth){ 
     Intent intent = new Intent(this, DisplayMessageActivity.class); 
     startActivity(intent); 
    }else{ 
     newFragment = new login(); 

      newFragment.show(getFragmentManager(), "missiles"); 


    } 
    localData= new LocalDataInterface(b,c); 
    if (savedInstanceState == null) { 
     getSupportFragmentManager().beginTransaction() 
       .add(R.id.container, new PlaceholderFragment()) 
       .commit(); 
    } 
} 

整个布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<LinearLayout 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:orientation="vertical"> 
    </LinearLayout> 

+0

你可以发布你的清单。另外你在哪里添加FrameLayout? – Libin

+0

发布您的布局和整个#onCreate方法。 – William

回答

0

1,你应该添加一个参考的Google Play-services_lib项目

2,在您的应用程序清单,你应该添加这(进入应用标签):

<meta-data 
    android:name="com.google.android.gms.version" 
    android:value="@integer/google_play_services_version" /> 

3您的设备必须有gapps已安装

0

除了@扎卡里建议的内容之外,请确保未勾选以下复选框。

Settings->Data Usage->Google Service->Restrict Background Data