2013-10-14 127 views
0

這是我第一次使用admob。下面是manifect文件和XML文件嘗試添加「AdMob」時出錯

井字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. 

爲什麼會收到這樣的下面的列表?請幫忙。

回答

1

您必須聲明你AdActivity如下(這是什麼要求你的logcat ):

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

感謝您的答覆。它把錯誤拿出來了,但現在它是空的! –

+0

您的'adUnitId =「a1525bbc8227f4a」'末尾有空格,這可能不正確。 – Szymon

+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"/> 
+0

感謝您的回覆。你的意思是刪除「xmlns:android =」http://schemas.android.com/apk/res/android「」並添加新的? –

+0

添加像這樣我編輯了我的答案 – Zohaib

+1

非常感謝您的回覆。 +1從我:) –