尝试添加“AdMob”时出错

时间:2013-10-14 10:28:05

标签: java android eclipse admob

这是我第一次使用admob。下面是显示文件和XML文件

井字Toe.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:stretchColumns="*" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:text="" />

            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:text="" />

            <Button
                android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:text="" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button4"
                android:layout_width="wrap_content"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:text="" />

            <Button
                android:id="@+id/button5"
                android:layout_width="wrap_content"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:text="" />

            <Button
                android:id="@+id/button6"
                android:layout_width="wrap_content"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:text="" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <Button
                android:id="@+id/button7"
                android:layout_width="wrap_content"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:text="" />

            <Button
                android:id="@+id/button8"
                android:layout_width="wrap_content"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:text="" />

            <Button
                android:id="@+id/button9"
                android:layout_width="wrap_content"
                android:layout_height="100dp"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:text="" />
        </TableRow>
    </TableLayout>




    <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"
        googleads:adSize="BANNER" 
        android:layout_alignParentBottom="true"
        googleads:adUnitId="a1525bbc8227f4a  " />


</RelativeLayout>

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.xxx.ticktacktoe"
    android:versionCode="1"
    android:versionName="1.0" >

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


    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/tic_tac_toe_logo"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.xxx.ticktacktoe.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>

          <activity android:name="com.google.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation"/>

    </application>

但问题是,每当我运行此应用时,我都会看到错误图片,广告应该出现的地方

enter image description here

LogCat显示以下错误列表

10-14 15:58:57.500: E/Ads(633): The android:configChanges value of the com.google.ads.AdActivity must include screenLayout.
10-14 15:58:57.500: E/Ads(633): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
10-14 15:58:57.510: E/Ads(633): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
10-14 15:58:57.510: E/Ads(633): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.
10-14 15:58:57.510: E/Ads(633): You must have AdActivity declared in AndroidManifest.xml with configChanges.

为什么我会这样?

2 个答案:

答案 0 :(得分:1)

在相对布局中添加此链接

修改

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

也改变你的清单

<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

答案 1 :(得分:1)

您需要按如下方式声明AdActivity(这是您的logcat中请求的内容):

    <activity 
        android:name="com.google.ads.AdActivity" 
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>