0

我在我的应用中添加了 AdMob。我已经阅读并完成了 firebase 的所有指令,这是我的大文件:

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
//compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services:9.0.0'
//compile 'com.google.android.gms:play-services:9.4.52'
compile files('libs/apache-httpcomponents-httpclient.jar')
compile 'com.google.maps.android:android-maps-utils:0.4.3'
compile 'com.twotoasters.clusterkraf:library:1.0.2'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:cardview-v7:24.0.0-beta1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.uncopt:android.justified:1.0'
compile 'com.google.firebase:firebase-core:9.0.0'
compile 'com.google.firebase:firebase-ads:9.0.0'

//compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.0@aar') {
    transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.3@aar') {
    transitive = true;
}
compile 'com.github.paolorotolo:appintro:4.0.0'
compile 'com.karumi:dexter:2.3.0'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.clans:fab:1.6.2'
//compile 'com.google.android.gms:play-services:10.0.1'
}

apply plugin: 'com.google.gms.google-services'

我在firebase上添加了我的应用程序和包名称的指纹

这是代码布局:

<LinearLayout
    android:layout_width="300dp"
    android:layout_height="250dp"
    android:layout_gravity="center"
    android:id="@+id/adLinear"
    android:layout_marginTop="10dp"
    android:background="#FFFFFF">
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="MEDIUM_RECTANGLE"
        ads:adUnitId="@string/banner_ad_unit_id"
        android:layout_marginTop="10dp">
    </com.google.android.gms.ads.AdView>
</LinearLayout>

现在,当我运行该应用程序时,我看不到真正的广告,而是显示横幅尺寸的一般 adMob 广告。我的代码中有问题,或者要查看我必须在 google play store 我的应用程序上公开的真实广告?

谢谢

当我运行应用程序时,我看到了类似的图像 在此处输入图像描述

我想如果是正确的,如果我必须在 google play 上发布应用程序才能看到真正的广告

4

1 回答 1

1
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/adLinear"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_marginTop="10dp"
    android:background="#FFFFFF">

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        ads:adSize="MEDIUM_RECTANGLE"
        ads:adUnitId="@string/banner_ad_unit_id"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"></com.google.android.gms.ads.AdView>
</LinearLayout>

在 java 文件中显示广告使用这个

private void adView() {
    mAdView = (AdView) findViewById(R.id.ad_view);
    MobileAds.initialize(getApplicationContext(), getResources().getString(R.string.admob_banner_id));
    final AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);
}

用这个替换你的代码。实际上问题是广告尺寸大于你的布局尺寸,这就是你面临这个问题的原因。

于 2016-12-23T11:49:47.633 回答