Admob横幅广告在Android上无法正常运行

时间:2015-01-10 05:32:06

标签: android admob adsense google-adwords

点击ADMOB-BANNER ADS时,我在logcat中收到消息

无法获取广告重叠式信息

您好我已经整合了admob,并遵循它的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:layout_width="match_parent"
    android:layout_height="match_parent" >

    <com.aviary.android.feather.library.services.drag.DragLayer
        android:id="@+id/dragLayer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/adView" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="?attr/aviaryBackgroundColor"
            android:orientation="vertical" >

            <!-- main navbar ( title, apply and done buttons ) -->

            <include
                android:id="@+id/aviary_navbar"
                layout="@layout/aviary_navbar" >
            </include>

            <!-- main content view -->

            <RelativeLayout
                android:id="@+id/main_content"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/aviary_bottombar"
                android:layout_below="@id/aviary_navbar"
                android:padding="?attr/aviaryMainImagePadding" >

                <!-- optional image view container -->

                <RelativeLayout
                    android:id="@+id/drawing_view_container"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >
                </RelativeLayout>

                <!-- main image view -->

                <com.aviary.android.feather.sdk.widget.AviaryImageViewUndoRedo
                    android:id="@+id/image"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="invisible" />

                <!-- main loader, visible while loading the image at start -->

                <include
                    android:id="@+id/image_loading_view"
                    layout="@layout/aviary_main_loader" >
                </include>
            </RelativeLayout>

            <!-- bottom bar (tools, panels) -->

            <include
                android:id="@+id/aviary_bottombar"
                android:layout_width="match_parent"
                android:layout_height="?attr/aviaryBottomBarHeight"
                android:layout_alignParentBottom="true"
                layout="@layout/aviary_bottombar" >
            </include>

            <!-- popup container dialog -->

            <RelativeLayout
                android:id="@+id/feather_dialogs_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/aviary_navbar"
                android:visibility="invisible" >
            </RelativeLayout>

            <!-- hidden surface view -->

            <SurfaceView
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:visibility="invisible" >
            </SurfaceView>
        </RelativeLayout>
    </com.aviary.android.feather.library.services.drag.DragLayer>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/banner_ad_unit_id" >
    </com.google.android.gms.ads.AdView>

</RelativeLayout>

这是Java代码

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

这是清单文件

<application>
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <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>

但每当点击横幅广告时,它会向我显示点击回复但不会转移到游戏商店或浏览

1 个答案:

答案 0 :(得分:1)

activity_main.xml中

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <!-- Creating AdView in XML and loading an ad -->

    <com.google.android.gms.ads.AdView
        android:layout_alignParentBottom="true"
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="(Here paste your google add key)" />

</RelativeLayout>

MainActivity.java

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Get the view from activity_main.xml
        setContentView(R.layout.activity_main);

        AdView mAdView = (AdView) this.findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder()
        // Add a test device to show Test Ads
        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
               .build();
        mAdView.loadAd(adRequest);
    }
}

的AndroidManifest.xml

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.test.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <!-- Include the AdActivity configChanges and theme. -->
    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent" />
    <!-- Google Play Service Meta-data Info -->
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
</application>