Kode Kode - 1 year ago 106
Android Question

How is AndroidManifest.xml validated in android studio?

How android studio validates AndroidManifest.xml and any activity xml? I have read this post and this and know that there isn't an actual schema for android manifest. But how does android studio or any tool that validates AndroidManifest.xml knows, what tags and elements are legal?

Answer Source

Everything can be found on the https://android.googlesource.com.

The manifest model is not written as .xsd file. Instead it is written as a group of objects. The tree can be found here

If you start from Manifest you can see, that it has the references to Application, List<UsesPermission>, etc. The Application has references to android:name and android:label and List<Activity> and so on.

A sample from Activity object:

AndroidAttributeValue<PsiClass> getActivityClass();

As you can see this is the way, that Android Studio knows, that activity tag inside manifest must have a name. Two annotations are used:


One of them is the name of .xml tag attribute, and the second one informs, that this attribute is required.

The names of tags, that can be used inside manifest can be found here

A helper class used by Android Studio to get manifest properties can be found here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download