-->

How to get rid of the warning: Use '$' ins

2020-08-09 08:50发布

问题:

I am new to Android development. After I updated my eclipse and Android SDK to the newest version, I got an warning:

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

I Found some information on this 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.)"

I believe that I used uppercase characters in sub package name like com.abc.app.Promotion.

The question is: What is the best way to get rid of this warning in the manifest.xml? It still can build and run but I find it so annoying.

I tried using refactor to rename the package and modified the manifest.xml android:name="com.abc.app.promotion.Promotion" but got this error:

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?

Thanks for helping!

EDIT: original manifest.xml

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

updated manifest.xml

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

回答1:

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.

I tried also to change only the first letter of the package name to be lower case, the warning disappeared.



回答2:

You must use lower case in your package name

or add this atrr in application tag

tools:ignore="InnerclassSeparator"

To Ignore this Waring