Android, Maven and AdMob
I'm moving my Android projects to Maven, and I'm having problems with one that uses AdMob.
I've installed the AdMob jar to my own repository, can build and deploy the app and ads are shown as expected. However, that is only if I delete the following three lines from my layout.xml (the AdView tag in partiular):
myappname:backgroundColor="#000000"
myappname:primaryTextColor="#FFFFFF"
myappname:secondaryTextColor="#CCCCCC"/>
If the lines are there, I get the following error messages in logcat:
[INFO] /home/futlib/Projects/myappname/myappname-free/res/layout/main.xml:9: error: No resource identifier found for attribute 'backgroundColor' in package 'com.example.myappname'
[INFO] /home/futlib/Projects/myappname/myappname-fre开发者_Python百科e/res/layout/main.xml:9: error: No resource identifier found for attribute 'primaryTextColor' in package 'com.example.myappname'
[INFO] /home/futlib/Projects/myappname/myappname-free/res/layout/main.xml:9: error: No resource identifier found for attribute 'secondaryTextColor' in package 'com.example.myappname'
[ERROR] Error when generating sources.
I'm not really sure why it works without these lines, but according to the resources I can find about AdMob, they should be there, so I'm wondering how I can make them work.
The very same project works in Eclipse, just not on the Maven command line. In case you're wondering, this is what my res/values/attrs.xml looks like:
<?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>
Any ideas?
Try adding the AdMob sdk to your build dependencies as described in this answer. Alternatively you might want to check out this answer.
精彩评论