2012-11-29 31 views
12

我是Android開發新手。我在我的Eclipse和Android SDK更新到最新版本後,我得到了一個警告:

Use '$' instead of '.' for inner classes (or use only lowercase letters in package names) AndroidManifest.xml 

我發現這個link一些信息。

"When you reference an inner class in a manifest file, you must use '$' instead of '.' " + 
    "as the separator character, e.g. Outer$Inner instead of Outer.Inner.\n" + 
    "\n" + 
    "(If you get this warning for a class which is not actually an inner class, it's " + 
    "because you are using uppercase characters in your package name, which is not " + 
    "conventional.)" 

我相信,我用大寫字符子包的名字像com.abc.app.Promotion

問題是:在manifest.xml中擺脫此警告的最佳方法是什麼?它仍然可以建立和運行,但我覺得它很煩人。

我試着使用重構重命名的包和修改的manifest.xml android:name="com.abc.app.promotion.Promotion"但得到這個錯誤:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.abc.app/com.abc.app.TabView}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.abc.app/com.abc.app.promotion.Promotion}; have you declared this activity in your AndroidManifest.xml? 

感謝您的幫助!

編輯: 原來的manifest.xml

<activity android:name=".Promotion.Promotion" ></activity> 

更新的manifest.xml

<activity android:name="promotion.Promotion" ></activity> 
+7

使用小寫字符只爲包名。 – Alex

+0

是的,我明白了。我在之前版本的SDK中發現了這個錯誤,沒有發出警告,現在想改回它。謝謝! – siutsin

+0

也發佈你的清單 – njzk2

回答

32

如果你得到這樣的警告一類。它實際上不是一個內部類,那是因爲你正在使用包名中的大寫字符,這不是傳統的。

我試過也只是把包名的第一個字母改成小寫,警告消失了。

0

最可能出現的問題是因爲在包名中使用大寫,因此將大寫更改爲小寫。如果警告仍然存在,

然後導入工具命名空間:

xmlns:tools="http://schemas.android.com/tools" 

則忽略特定元素上的警告:

tools:ignore="InnerclassSeparator"