Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android XML comments with double dashes

I just obtained a debug Google Maps API key for my new MacBook, and Google spit back a key with double dashes ("--") in it. I normally put all of our debug keys in comments so that others can store their keys in the source and copy/pasta as necessary. Out of convenience for the team, really.

The compiler throws a fit when you have these double dashes in comments. Is there a way to escape or otherwise encode my key so I can store it in a comment?

Example:

    <com.google.android.maps.MapView 
    android:id="@+id/mapview_map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
      android:apiKey="ABCDEFABCDEFABCDEF0123456789--123456789" />
    <!--  android:apiKey="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" />  CERT KEY --> 
    <!--  android:apiKey="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" />  Sally debug Key -->
    <!--  android:apiKey="ABCDEFABCDEFABCDEF0123456789--123456789" />  Joe debug key -->
like image 748
Joe Sines Avatar asked Jun 09 '26 19:06

Joe Sines


1 Answers

According to the XML standard, no: http://www.w3.org/TR/REC-xml/#sec-comments

I'd recommend just picking another character not in 0-9,A-F that everyone will understand means dash, like an underscore. -- inside of an XML comment invalidates the XML, and there's no way around it.

like image 61
David Merriman Avatar answered Jun 11 '26 22:06

David Merriman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!