2017-03-07 85 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

是的,我做到了。没有填充。我甚至删除了高于它的图像视图。 –