简体   繁体   中英

Error - The processing instruction target matching “[xX][mM][lL]” is not allowed

I am not an Android Developer and Java is sort of Alien to me.

I was building my first react-native-app and was building a splashscreen which requires you to fiddle with Android

So, I was reading this article on the web to create a splashScreen

When I ran my app, it threw an error saying that

The processing instruction target matching "[xX][mM][lL]" is not allowed.

The directory which It pointed to have an issue is consist just few lines of code

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="blue">white</color>
</resources>

Which still happens to be the equivalent of what author have done

The complete error would be

What went wrong: Execution failed for task ':app:mergeDebugResources'.

/Users/anilbhatia/Desktop/Crypto-Main/Crypto-frontend/android/app/src/main/res/values/colors.xml:2:6: Error: The processing instruction target matching "[xX][mM][lL]" is not allowed.

Question: How to fix it or what I would've done wrong here? Also I am not sure what all code I need to share so please spoon feed me if I need to share additional details.

Update: Okay, It looks like that problem have been solved, I had a blank line before start of my XML. There shouldn't be anything before the XML and I was also having color code problem (check answer).

You need to define the color value instead of color name so use (change the name of the color )

 <color name="blue">#ffffff</color>

or you can use inbuilt colors as

 <color name="blue">@android:color/white</color>

Tip: click on the color icon on left to open the color picker

The XML Color tag takes in an hexadecimal value, not a name.

So use this to get a blue color

<color name="blue">#0000ff</color>

and then call it using @color/blue in your XML file Alternatively you can use android's color values using @android:color/holo_blue_dark if you don't wanna define your custom color

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM