This question already has answers here:
Error: The processing instruction target matching "[xX][mM][lL]" is not allowed
(10 answers)
Closed 3 years ago.
I'm trying to implement facebook login in my app so I followed facebook instructions and I needed to create strings.xml file because I didn't have this file, but when I start the app I get this error:
Execution failed for task ':app:mergeDebugResources'.
Error: The processing instruction target matching "[xX][mM][lL]" is
not allowed.
My strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">name</string>
<string name="facebook_app_id">00000000000</string>
<string name="fb_login_protocol_scheme">fb000000000000</string>
</resources>
What should I do to solve this problem?
Leave out the <?xml ...> XML declaration alltogether. This error is reported when an XML declaration (which is syntactically an SGML processing instruction) is found in XML other than at the beginning of the XML. So I'm guessing the XML is composed/appended to some other XML in your app (it's impossible to say without additional info). An XML declaration is optional anyway; it's only used to tell a parser the encoding of the document, and that markup should be parsed according to XML rules (rather than HTML or generic SGML rules). You also might want to double-check you put no invisible garbage characters (by string operations in your app code) into your XML.
Related
I have finished to write my small program and now I want to add locale.
Before I had next structure: /res/value/strings.xml
I have added to the structure new folder with file with another language:
/res/value-uk/strings.xml (it's ukrainian language)
after that I built my APK in AndroidStudio and I got error:
Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
Unknown failure (Failure)
Error while Installing APK
I was searching this problem in google and nothing helped me.
Please reccomend me how to solve this problem. Thank you.
I had the same problem and I found a lot of people managed to solve the problem by adding the full package name inside the various manifest "android:name".
It didn't work for me and I found out that my problem was different:
I had two string files, "strings.xml" and "strings-en.xml. In the former one I had some values with the field "translatable=false", such as:
<string name="db_name" translatable="false">my_db</string>
To solve the problem I had to REMOVE that string resource from the strings-en.xml, in order to have those strings only in the default strings.xml.
I hope this can help future developers.
The xliff namespace declaration in your strings.xml file seems to be wrong. Try using <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"> instead. Or strip out all the <xliff:g> tags and see if it makes a difference - they are not needed any more after translation. And Chol is right: the default folder name for Ukrainian is values-uk, not value-uk.
This question already has answers here:
Android Studio - mergeDebugResources exception
(15 answers)
Closed 7 years ago.
well my problem is that i want to create two strings.xml each contaniing different text and i want to read these texts from different activities but am getting 1 error(HELP ME PLEASE).By the way i tried to create a new resourse file named strings2.xml...here is the error:
Error:Execution failed for task ':app:mergeDebugResources'.
[string/action_settings] C:\Users\DELL\AndroidStudioProjects\TestScrollView\app\src\main\res\values\strings.xml [string/action_settings] C:\Users\DELL\AndroidStudioProjects\TestScrollView\app\src\main\res\values\strings2.xml: Error: Duplicate resources
[string/app_name] C:\Users\DELL\AndroidStudioProjects\TestScrollView\app\src\main\res\values\strings.xml [string/app_name] C:\Users\DELL\AndroidStudioProjects\TestScrollView\app\src\main\res\values\strings2.xml: Error: Duplicate resources
If it says that action_settings or app_name are defined in both, it pretty sure is. :-) Why do you need two string XMLs in the first place? No matter what activity you call them from, all strings can go easily into one. If you want to differentiate the strings (not for the compiler but for yourself), use different something_ prefixes.
To put it into perspective, an activity is more or less like a window in other operating systems. You have one application that can have several pages or windows or activities, whichever you name it. Your resources (strings, layouts, drawables, menus, etc) belong to the application, not to one of the activities. So, from any activity in the application, you simply refer to the same strings, same resources. Inside an activity there is a helper function that allows you to get a string directly, without calling it through getResources() because it's such an often needed operation but your program does the same in both cases:
getResources().getString(R.string.xxx)
getString(R.string.xxx)
getResources().getDrawable(R.drawable.xxx)
So, if you have a string called actions_settings:
<resources xmlns:tools="http://schemas.android.com/tools">
...
<string name="actions_settings">...........</string>
...
</resources>
you just refer to it with:
getString(R.string.actions_settings)
no matter which of your app's activities you're currently in.
I am trying to transform the android xml into Plist but i am facing the issue because the Android XML contains COLONS in the attribute names as follows:
<PreferenceCategory android_title="Identity" >
<EditTextPreference
android:key="systemname"
android_title="System Name" />
</PreferenceCategory>
So when i try to read the attribute value using XSLT it gives the following error:
XPath evaluation returned no result.
I am bit new to XSLT, So can any one help me reading the attribute value which have colon in their names as mentioned above.
Please read about XML Namespaces, a good starting point can be XML Namespaces tutorial on w3schools.com to know about the usage of "colons".
You could read the MSDN article about XML Namespaces and How They Affect XPath and XSLT to know more.
I managed by using the exclude-result-prefixes attribute inside in XSLT.
My stylesheet tag looked like below.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:android="http://schemas.android.com/apk/res/android"
exclude-result-prefixes="android">
exclude-result-prefixes attribute is used if you want to exclude any namespace during compile time.
I am using a Java class to import data to my app from a .csv file. I found some examples online, and this is what they seem to do. However, it's showing the error: Error parsing XML: unbound prefix. The research I've done on this indicates that it is usually a spelling error. If it is, I can't find it. Here is the section where I am having the problem.
<provider android:name="com.ATS_Boxes.ContentProvider.class"
android:authorities="ContentProvider"></provider>
You appear to be trying to declare a provider in an Android resource file - that isn't possible. You can only declare providers in your project's manifest file (AndroidManifest.xml, in the root directory of your project).
Also, although I'm not sure if it makes any difference, the first line in the xml code you provided as comment reads:
<!--?xml version="1.0" encoding="utf-8"?-->
That looks like it's commented out. Normally it should look like:
<?xml version="1.0" encoding="utf-8"?>
post the entire XML file.
My guess is that you do not have the 'android' namespace declared so its puking when it's parsing the attributes android:name and android:authorities
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Parse local XML file in Android
hi. I want to know how to load and how to parse this XML file from res/xml, and how to rewrite the values
<?xml version="1.0" encoding="UTF-8"?>
<Rocket>
<body>baby</body>
<launcher>basic</launcher>
<point>0</point>
<money>0</money>
<highest>0</highest>
<levelReached>1</levelReached>
</Rocket>
I've never playing with XML before so I feel so blind about this. I already done searching and all I found is about reading XML files from the internet. I didn't find any tutorial of how to parse xml for game use.
and for the additional question,I don't really understand the terms in xml. what is the meaning of serialization? what is DOM? SAXParser? PullParser?
DOM is a generic in-memory representation (nodes and pointers) of you XML data. SAX is a parsing API that generates (pushes) parsing events while streaming the XML input file. PullParser is similar but pull-based.
If you just want to get "that data" into your code you might want to go for XML data binding: http://en.wikipedia.org/wiki/XML_data_binding
It will generate source code of classes matching the structure of the XML data. Afterwards you can easily convert XML to objects and back. That's called (un)marshalling and is similar to (de)serialization.