4

I have the following piece of code in my AndroidManifest.xml file in which I want to comment out a single line (for quick testing purposes). By choosing the AndroidStudio-comment function I get the following:

<application
    android:allowBackup="true"
    android:icon="@mipmap/myicon"
    android:label="@string/app_name"
    android:supportsRtl="true"
    <!--android:theme="@style/AppTheme"-->
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar" >

However, this creates a compilation error:

Error:Element type "application" must be followed by either attribute specifications, ">" or "/>".

Is there a simple way to comment out a (block of) line(s), or should I open an external text editor and copy-and-paste the original (block of) line(s) to that external text editor?

Alex
  • 41,580
  • 88
  • 260
  • 469

5 Answers5

3

You can comment out side the tag Like :

<application
    android:allowBackup="true"
    android:icon="@mipmap/myicon"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar" >

 <!--android:theme="@style/AppTheme"-->

Not inside the tag.

R_K
  • 803
  • 1
  • 7
  • 18
  • This seems to work. Not optimal, but better to copy all to another file. Wonder why AndroidStudio does not know about that... – Alex Oct 27 '15 at 13:47
1

It is not possible in xml, if you want to add comments then you have must use xml syntax and syntax is use comments before starting or ending of tag

Yogesh Rathi
  • 6,331
  • 4
  • 51
  • 81
0

You cannot put comments inside tags. Please see the answer to this question.

Community
  • 1
  • 1
gonzobrains
  • 7,856
  • 14
  • 81
  • 132
0

XML does not allow comments within a tag. You can only comment out elements as a whole.

Henry
  • 42,982
  • 7
  • 68
  • 84
0

You need to place it outside. See reference: here

jean d'arme
  • 4,033
  • 6
  • 35
  • 70