gpt4 book ai didi

java - 尝试添加时出错 "AdMob"

转载 作者:行者123 更新时间:2023-12-02 06:38:49 25 4
gpt4 key购买 nike

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

Tic-Tac-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>

list 文件

<?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.

为什么我会得到这个?

最佳答案

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

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

关于java - 尝试添加时出错 "AdMob",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19358208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com