2011-06-04 69 views
2

我正在將我的Android項目移至Maven,並且遇到使用AdMob的問題。Android,Maven和AdMob

我已將AdMob jar安裝到我自己的存儲庫中,可以構建和部署應用程序,並按預期顯示廣告。然而,這只是如果我刪除我的layout.xml以下三行(在partiular AdView標記):

myappname:backgroundColor="#000000" 
myappname:primaryTextColor="#FFFFFF" 
myappname:secondaryTextColor="#CCCCCC"/> 

如果線條都在那裏,我得到的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-free/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. 

我不確定它爲什麼沒有這些行,但根據我可以找到關於AdMob的資源,他們應該在那裏,所以我想知道如何讓他們工作。

同樣的項目在Eclipse中工作,只是不在Maven命令行上。如果你想知道,這是我的res/values/attrs.xml看起來像︰

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

任何想法?

回答

0

嘗試將AdMob sdk添加到您的構建依賴關係中,作爲described in this answer。 或者,您可能想查看this answer

+0

第一個答案描述瞭如何將AdMob添加到Maven,我已經這樣做了。第二個答案似乎並不涉及我的問題。請注意,廣告已顯示,只是我無法設置這些參數。另請注意,Maven項目使用與Eclipse項目相同的_exact_相同的AdMob JAR--在這裏一切正常。 – futlib 2011-06-08 17:07:34