Android - Admob issues!
So I'm trying to just add a simple ad to my app using admob. I've followed the tutorial with the SDK but am getting stuck at one error.
Here's the error:
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'
so I figure it must be a problem with my package name but as far as I can see everything is OK.
In my layout file I have the following:
<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" >
But the package name seems correct:
package man.utd.headlines.man.utd;
Any开发者_如何学运维 ideas? It's very frustrating!
I have also checked my manifest and have tried with this package name but it still doesn't work:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="man.utd.headlines"
Any help is greatly appreciated.
UPDATE: Solved by changing package names to make them more consistant - they mnust be exactly the same in main class and manifest!
New Problem: Ads won't display!
Heres my layout file:
<?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" />
Any ideas? Any help greatly appreciated :).
Does your attrs.xml(in res/values folder) file look like this:
<?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>
If not, create an xml file names attrs.xml in your res/values folder and copy this code into it.
For the new Google version of admob your attrs.xml file now should look like this:
<?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>
精彩评论