2

そのため、admob を使用してアプリに簡単な広告を追加しようとしています。SDK を使用してチュートリアルに従いましたが、1 つのエラーで行き詰まりました。

エラーは次のとおりです。

Multiple annotations found at this line:
- ERROR No resource identifier found for attribute 'secondaryTextColor' in package 
 'man.utd.headlines.man.utd'
- ERROR No resource identifier found for attribute 'primaryTextColor' in package 'man.utd.headlines.man.utd'
- ERROR No resource identifier found for attribute 'backgroundColor' in package 'man.utd.headlines.man.utd'

パッケージ名に問題があるに違いないと思いますが、私が見る限り、すべて問題ありません。

私のレイアウトファイルには次のものがあります:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines.man.utd"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >

しかし、パッケージ名は正しいようです:

package man.utd.headlines.man.utd;

何か案は?とてもイライラします!

マニフェストも確認し、このパッケージ名で試しましたが、まだ機能しません:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="man.utd.headlines"

どんな助けでも大歓迎です。

更新:パッケージ名を変更してより一貫性を持たせることで解決しました-メインクラスとマニフェストでまったく同じである必要があります!

新しい問題: 広告が表示されない!

Heres私のレイアウトファイル:

<?xml version="1.0" encoding="utf-8"?>

<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

 <com.admob.android.ads.AdView 
    android:id="@+id/ad"
    android:layout_width="fill_parent"
    android:layout_height="100px"
    myapp:backgroundColor="#000000"
    myapp:primaryTextColor="#FFFFFF"
    myapp:secondaryTextColor="#CCCCCC" />

何か案は?どんな助けでも大歓迎です:)。

4

2 に答える 2

4

attrs.xml (res/values フォルダー内) ファイルは次のようになっていますか?

  <?xml version="1.0" encoding="utf-8" ?> 
    <resources>
      <declare-styleable name="com.admob.android.ads.AdView">
        <attr name="backgroundColor" format="color" /> 
        <attr name="primaryTextColor" format="color" /> 
        <attr name="secondaryTextColor" format="color" /> 
        <attr name="keywords" format="string" /> 
        <attr name="refreshInterval" format="integer" /> 
      </declare-styleable>
    </resources>

そうでない場合は、res/values フォルダーに attrs.xml という名前の xml ファイルを作成し、このコードをそこにコピーします。

于 2010-08-31T23:00:54.487 に答える
2

新しいGoogleバージョンのadmobの場合、attrs.xmlファイルは次のようになります。

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <declare-styleable name="com.google.ads.AdView">
      <attr name="adSize">
          <enum name="BANNER" value="1"/>
          <enum name="IAB_MRECT" value="2"/>
          <enum name="IAB_BANNER" value="3"/>
          <enum name="IAB_LEADERBOARD" value="4"/>
      </attr>
      <attr name="adUnitId" format="string"/>
      <attr name="backgroundColor" format="color" />
      <attr name="primaryTextColor" format="color" />
      <attr name="secondaryTextColor" format="color" />
      <attr name="keywords" format="string" />
      <attr name="refreshInterval" format="integer" />
  </declare-styleable>
</resources>
于 2011-05-05T18:03:24.933 に答える