题
所以我想只需添加一个简单的广告使用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'
所以我想,这一定是我的包名称的问题,但据我所看到的一切都OK。
在我的布局文件我有以下:
<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"
任何帮助不胜感激。
更新:通过改变包装的名称解决,使他们更洽 - 他们mnust在主类和清单
一模一样!新问题:广告将不会显示
下面有我的布局文件:
<?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" />
任何想法?任何帮助不胜感激。)
解决方案
贵attrs.xml(在res /文件夹值)文件是这样的:
<?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文件的名称在资源attrs.xml /值文件夹,这个代码复制到它。
其他提示
有关新的谷歌Android2.1版本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>
不隶属于 StackOverflow