2017-11-04 6 views
1

こんにちは、私のアプリにバナーを追加しようとしています。私は正しいと思う適切な方法でユニットIDとアプリIDを追加しましたが、広告は読み込まれず、 私はバナーの場所に問題がないと思います。その場所は空のままで、別のアクティビティに表示しようとしますが、私は同じ結果を得ます。 私はのonCreateでMainActivity.javaそれは次が含まれています:load admobはアンドロイドアプリで動作していません

MobileAds.initialize(this, "ca-app-pub-*****************~**********"); 

mAdView = (AdView) findViewById(R.id.adView); 
    AdRequest adRequest = new AdRequest.Builder().build(); 
    mAdView.loadAd(adRequest); 

activity_main.xml:コード内の変更は何もせずに今取り組ん

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
android:id="@+id/outer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 
<android.support.v4.widget.DrawerLayout 
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" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
android:layout_above="@+id/adView" 
tools:openDrawer="start"> 


<include 
    layout="@layout/app_bar_main" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_above="@+id/adView" 
    /> 

<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:fitsSystemWindows="true" 
    app:menu="@menu/activity_main_drawer" /> 
     </android.support.v4.widget.DrawerLayout> 

    <com.google.android.gms.ads.AdView 
    xmlns:ads="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/adView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    ads:adSize="BANNER" 
    ads:adUnitId="ca-app-pub-****************/**********"> 
    </com.google.android.gms.ads.AdView> 

</RelativeLayout> 
+1

実際のデバイスまたはエミュレータで確認していますか? – Munir

+0

実際のデバイスで! –

+0

同じ方法で広告サイズと広告ユニットIDを設定してください(つまり、XMLまたはプログラムで両方を設定する)。 –

答えて

0

そのを、私はそれが

を有効にするには、いくつかの時間を必要だと思います
関連する問題