Вопрос

Поэтому я пытаюсь просто добавить простое объявление в мое приложение, используя Admob. Я последовал за руководством с SDK, но я застрял по одной ошибке.

Вот ошибка:

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"

Любая помощь значительно ценится.

Обновление: решается путем изменения имен пакетов, чтобы сделать их более согласованными - они не имеют бы совпадают в основном классе и проявляются!

Новая проблема: ADS не будет отображаться!

Вот мой файл макета:

<?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" />

Есть идеи? Любая помощь очень ценится :).

Это было полезно?

Решение

Есть ли в вашем файле Abts.xml (в папке Res / value / state):

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

Если нет, создайте имена файлов XML Abtrs.xml в папке RES / значения и скопируйте этот код в него.

Другие советы

Для новой версии 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>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top