0
我已經在AdMob上註冊,並收到應用程序ID,所以廣告假設出現在activity_main.xml中,但它只是需要空間,而不顯示這裏的任何東西是activity_main.xml中AdMob不顯示
代碼<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'
缺少google_app_id。 Firebase Analytics已停用。 _____ GoogleService無法初始化,狀態爲10,缺少名稱爲google_app_id.Missing的字符串資源中的Google應用程序ID值。google_app_id ._______ Firebase Analytics disabled.that這就是我在logcat中發現的任何建議? – LCTS
仔細檢查日誌。該日誌與Firebase分析相關,與廣告無關。您可以通過正確鏈接文件google-services.json來修復該Firebase錯誤。 –