Omitting the dot and not fully qualifying the package/class name will work if and only if the specified class is not part of a subpackage within your application.
If your application package name is com.example.myapp
, and you have an activity class com.example.myapp.MyActivity
:
android:name="MyActivity"
will work.
android:name=".MyActivity"
will work.
android:name="com.example.myapp.MyActivity"
will work.
But if you have the same application package and an activity class in a subpackage within your source tree such as com.example.myapp.myactivities.MyActivity
things change.
android:name=".myactivities.MyActivity"
will work
android:name="com.example.myapp.myactivities.MyActivity"
will work
android:name="MyActivity"
will not work
android:name="myactivities.MyActivity"
will not work
3 doesn't work because that will infer that the class name you mean is actually com.example.myapp.MyActivity
like in the first example above. A class with this name won't be found and you'll get an error.
4 doesn't work because it looks like a fully qualified class name, that is the system will interpret it to mean that myactivities.MyActivity
is the fully qualified name itself, not the real name of com.example.myapp.myactivities.MyActivity
.
You need the leading dot here to clarify that you're using a relative path, not an absolute path. If you specify just a class name with no package info at all, the system infers that the class is at the root of your application package hierarchy.