2017-03-07 83 views
1

已經嘗試了很多東西。浪費了一天,看起來很容易。 當我打開我的應用程序時,廣告不顯示。」廣告不可見,不會刷新廣告。「

一切正常無誤,但只是廣告根本不顯示。

代碼和logcat的如下

MainActivity.java

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    MobileAds.initialize(getApplicationContext(), "***"); 


    // " *** " is replacement for AdID and AdunitID 
    setContentView(R.layout.activity_main); 


    adView = (AdView)this.findViewById(R.id.adView); 
    AdRequest adRequest = new AdRequest.Builder() 
      .addTestDevice("45051C497E3954E140EC02E9C7B31B3C") 
      .build(); 

    adView.loadAd(adRequest); 

} 

XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 


    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" 
    android:paddingTop="16dp" 
    android:paddingBottom="16dp" 
    tools:context="a1440.MainActivity" 
    android:elevation="1dp" 
    android:padding="15dp"> 


    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     ads:adSize = "BANNER" 
     ads:adUnitId= "******" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="16dp" /> 

的logcat:

W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 16437 

I/chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest  
https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.appcache", source:  htt://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0) 

I/chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source:  htt://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0) 

I/chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source:  htt://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0) 

I/Ads: Ad is not visible. Not refreshing ad. I/Ads: Scheduling ad refresh 60000 milliseconds from now. I/Ads: Ad is not visible. Not  refreshing ad. 

I/Ads: Scheduling ad refresh 60000 milliseconds from  now. 
+0

你確定你在MainActivity中調用了像'adView.onResume()','onPause()'等嗎? – Sufian

回答

0

您已爲您的RelativeLayout聲明瞭左側和右側填充。這幾乎肯定會爲AdView留下太小的橫向空間。

+0

這是一個非常聰明的猜測,但沒有,仍然沒有工作。我試圖在一個新的虛擬項目中製作,但仍然看不到廣告。我已經安裝了播放服務和一切。 –

+0

您是否從「RelativeLayout」和「AdView」中刪除了所有填充項? – William

+0

是的,我做到了。沒有填充。我甚至刪除了高於它的圖像視圖。 –