Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is AndroidManifest.xml validated in android studio?

How does android studio validate 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?

like image 374
Vivin Avatar asked Sep 11 '16 22:09

Vivin


People also ask

What is AndroidManifest XML in Android Studio?

Every app project must have an AndroidManifest. xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.

Where is the AndroidManifest XML file in Android Studio?

Every project in Android includes a Manifest XML file, which is AndroidManifest. xml, located in the root directory of its project hierarchy. The manifest file is an important part of our app because it defines the structure and metadata of our application, its components, and its requirements.

How do I open AndroidManifest XML on Android?

Procedure. Open your Android project and go to <AppProjectFolder>/app/src/main/. Open the app manifest file AndroidManifest. xml and add the following lines to the file as child elements of the <manifest> element.

Where is Android App SRC main AndroidManifest XML?

xml ​ Android apps manage permissions, device features, and other settings in the AndroidManifest. xml file, which is located at android/app/src/main/AndroidManifest.


1 Answers

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:

@Attribute("name")
@Required
@Convert(PackageClassConverter.class)
@ExtendClass("android.app.Activity")
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:

@Attribute("name")
@Required

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

like image 97
R. Zagórski Avatar answered Oct 05 '22 12:10

R. Zagórski