Android App XML Parsing Error - android

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

Related

Android layout ids not recognised

I'm trying to get Android studio to recognise IDs of various views etc. in my layout.xml file. When I was inputting the code in the xml, everything seemed OK, but when I revisited my code today, the ids in the layout file were in red saying "cannot resolve symbol."
When I tried to access the view (eg using "view.findViewById(R.id.splo)"), it says it cannot resolve the symbol (in this case "splo").
I'm not doing anything radical, for instance this is how I define splo in my layout xml:
<TextView android:id="#+id/splo" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="" />
Doing some digging, I found that I don't have a res/values/id.xml file - and looking further I don't have anything below app/build/generated/source, so no R.java file either.
I've looked at some people's requests for help - one was very similar to mine ("cannot resolve symbol R" in Android Studio) but the solutions offered don't help.
I've done multiple invalidate cache and restart, with or without Build->clean project and nothing works, and the IDs are still not recognised. Can anyone help?
Well there might be potential errors in the package name when you are building your application.
Since you mentioned, you already tried rebuilding and cleaning the project, we won't waste time doing that again!
What I want you to do now is:
Open your AndroidMainfest.xml file
Scroll to the top and check is the package name is correct
If its correct then go to the Activity definitions in the manifest and check:
If the package name in these lines [android:name="YOUR_PACKAGE_NAME.YOUR_ACTIVITY_NAME"] is correctly assigned
If you see the above line is in this format [android:name=".YOUR_ACTIVITY_NAME]", then bring it in the above format by adding the package name before the dot.
Now clean and rebuild your project.
The problem should be solved and if not my request is that please
Upload your AndroidManifest.xml file and your package
information so that I can have a better look at the issue

How to solve ""[xX][mM][lL]" is not allowed" error [duplicate]

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.

Android - Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]

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.

Error parsing XML: Prefix must not be bound to reserved namespace explicitly

I cannot fix this error even after trying the mentioned techniques in other posts. I don't have crashlytics in my application. It's rather simple.
The issue persists even after cleaning the build and invalidating caches.
The following code is present in the values.xml file with a curly red line under the resources keyword.
<resources
xmlns:ns1="urn:oasis:names:tc:xliff:document:1.2"
xmlns:ns2="http://schemas.android.com/tools"
xmlns:ns3="http://www.w3.org/2000/xmlns/">
...
I know this question was asked a few times but I'm not able to fix the error in my application.
The declaration of ns3 is invalid because the namespace URI http://www.w3.org/2000/xmlns/ is reserved.
See section 3 of the XML Namespaces 1.1 specification at http://www.w3.org/TR/xml-names11/
The prefix xmlns is used only to declare namespace bindings and is by
definition bound to the namespace name http://www.w3.org/2000/xmlns/.
It must not be declared or undeclared. Other prefixes must not be
bound to this namespace name, and it must not be declared as the
default namespace. Element names must not have the prefix xmlns.

XSLT: Colon in attribute name in source XML

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.

Categories

Resources