谷歌广告没有与我合作

时间:2013-04-30 22:07:04

标签: java android admob

HELO

我用这个

<com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="a1517edc9c6ed63" />

和java

 AdView adView = (AdView)this.findViewById(R.id.adView);
            adView.loadAd(new AdRequest());

和AndroidManifest

<activity android:name="com.google.ads.AdActivity"
                  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    </application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>

和我带来了exetrnal JAR(GoogleAdMobAdsSdk-6.4.1)

但他没跟我合作。

1 个答案:

答案 0 :(得分:0)

上的布局xml文件中添加此行

的xmlns:应用= “http://schemas.android.com/apk/lib/com.google.ads”

就像这样

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
    android:id="@+id/LinearLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
    <com.google.ads.AdView
        xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@+id/ad"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="0dp"
        app:adSize="BANNER"
        app:adUnitId="@string/admob_id" >
    </com.google.ads.AdView>
</LinearLayout>
 </LinearLayout>