AdMob未在android中加载

AdMob未在android中加载,android,android-fragments,admob,adsense,Android,Android Fragments,Admob,Adsense,我正在尝试在我的应用程序中实现AdMob,我对Android的开发还相当陌生。 我的要求是,当用户单击一个按钮时,应该会显示一个弹出对话框,在下载我的文件时,该对话框下面应该有一个AdMob和一个进度条 但问题是AdMob根本没有加载 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:a

我正在尝试在我的应用程序中实现AdMob,我对Android的开发还相当陌生。 我的要求是,当用户单击一个按钮时,应该会显示一个弹出对话框,在下载我的文件时,该对话框下面应该有一个AdMob和一个进度条

但问题是AdMob根本没有加载

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="30dp"
    android:minWidth="300dp"
    android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:layout_marginTop="10dp">

    <com.google.android.gms.ads.AdView
        android:id="@+id/bannerAdView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_gravity="center"
        android:layout_margin="10dp"
        ads:adSize="MEDIUM_RECTANGLE"
        ads:adUnitId="@string/ad_banner_unit" />
</LinearLayout>

<ProgressBar
    android:id="@+id/download_progress_indicator"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center|bottom"
    android:layout_margin="10dp"
    android:layout_weight="1" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/cancel_download_action"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="center|bottom"
    android:layout_margin="20dp"
    android:layout_weight="1"
    android:src="@drawable/ic_close_black_24dp" />
</LinearLayout>
根据我的代码,只有当广告加载失败或已完成时,才会进行下载

不知怎的,这条线


被点击,但广告不显示。有人能告诉我为什么…以及如何修复它吗?

您的活动是否使用对话框主题
android:theme=“@android:style/theme.dialog”
?如果是,尝试切换到横向或使用一个正常的主题,并检查广告是否显示。如果是这样的话,问题可能是没有足够的空间来展示广告


您可以在横向布局中显示广告,或者尝试将广告宽度更改为“包裹内容”,大小更改为“智能条幅”

谷歌AdMob本身似乎存在一些问题……它现在的加载非常好,尝试将广告:adSize=“MEDIUM\u RECTANGLE”更改为ads:adSize=“SMART\u BANNER”。@Vinet Verma。
  AdView mAdView = (AdView) view.findViewById(R.id.bannerAdView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
    mAdView.setAdListener(new AdListener() {

        @Override
        public void onAdFailedToLoad(int errorCode) {
            Log.d(TAG, "onAdFailedToLoad: " + errorCode);
            downloadFile(view);
            super.onAdFailedToLoad(errorCode);
        }

        @Override
        public void onAdLoaded() {
            Log.d(TAG, "onAdLoaded: loaded");
            downloadFile(view);
            super.onAdLoaded();
        }
    });
Log.d(TAG, "onAdLoaded: loaded");