"广告不可见。没有刷新广告。"

时间:2017-03-07 20:29:04

标签: android admob

尝试了很多东西。浪费了一天似乎很容易的东西。 当我打开我的应用时,广告就不会显示。

一切正常,但广告根本不显示。

代码和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.

1 个答案:

答案 0 :(得分:0)

您已为RelativeLayout声明了左右填充。这几乎肯定会为您的AdView留下太少的横向空间。