【问题标题】:Admob does not displayAdmob 不显示
【发布时间】:2017-09-24 01:38:01
【问题描述】:

我已经注册了 adMob 并且我得到了一个应用 ID,所以广告假设出现在 activity_main.xml 中,但它只是占用一个空间而不显示任何内容这里是 activity_main.xml 的代码

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            xmlns:tools="http://schemas.android.com/tools"
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            tools:context="com.android.homeexercises.MainActivity"
            >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="#0000"
   >
 <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id">
    </com.google.android.gms.ads.AdView>

</LinearLayout>
</ScrollView>

MainActivity 类中的代码:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        AdView mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);
    }

清单中的代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.afai_aapps109.android">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
       >

        <meta-data android:name="com.google.android.gms.version"
                   android:value="@integer/google_play_services_version" />
        <activity android:name="com.android.homeexercises.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name="com.google.android.gms.ads.AdActivity"
                  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
                  android:theme="@android:style/Theme.Translucent" />
    </application>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>

和 gradle 中的库:

compile 'com.google.android.gms:play-services:11.0.0'

【问题讨论】:

    标签: android google-play admob google-play-services


    【解决方案1】:

    检查日志。您应该会看到类似

    的内容

    未能加载广告:3

    错误代码可能是 0 到 3。 从此处检查文档中的错误代码。 https://developers.google.com/android/reference/com/google/android/gms/ads/AdRequest#ERROR_CODE_NO_FILL

    【讨论】:

    • 缺少 google_app_id。 Firebase 分析已停用。 _____ GoogleService 初始化失败,状态:10,缺少名称为 google_app_id 的字符串资源中的 google 应用程序 ID 值。缺少 google_app_id。_______ Firebase Analytics 已禁用。这就是我在 logcat 中找到的,有什么建议吗?
    • 仔细检查日志。该日志与 Firebase 分析有关,与广告无关。您可以通过正确链接文件 google-services.json 来修复该 firebase 错误。
    猜你喜欢
    • 2021-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多