I am new to Xamarin and especially xml, but I have run into a problem that I have not been able to resolve with any solution after hours of searching. I am trying to use the "android.support.percent" package to use percent margins on a relative layout. I have installed the proper NuGet packages to support it too. It worked for a little while, but now it has suddenly started giving me multiple warnings and messages throughout the file.
The first error is simply "The 'PercentRelativeLayout' attribute is not declared." This is just the name given to my starting xml tag. Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/percentRelativeLayout"
android:background="#000000">
Second, four warnings appear in the AndroidManifest with a similar message: "The 'http://schemas.android.com/apk/res/android:xxxx' attribute is not declared." where 'xxxx' is versionCode, versionName, label, and icon. The manifest file is not very extensive at all:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="MyProject.MyProject" android:versionCode="1"
android:versionName="1.0">
<uses-sdk />
<application android:label="MyProject"
android:icon="#drawable/Icon"></application>
</manifest>
On top of all this, there are 4 messages showing that say:
"Could not find schema information for the element 'manifest'."
"Could not find schema information for the attribute 'package'."
"Could not find schema information for the attribute 'uses-sdk'."
"Could not find schema information for the element 'application'."
What does all this mean and how can I get back to actually developing this app?
Figured it out myself, I am not very good at this. The tag must be .
The manifest errors, I don't know, but they seemed to resolve themselves.
The definition is:
<android.support.percent.PercentRelativeLayout>
You need to include the proper package name to this layout or else it will not be found.
As for the AndroidManifest.xml this looks fine from a first glance.
Related
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
When you want to import attributes in AndroidManifest.xml you have to kind of import their libraries. which you can then access by their prefixs {android:,tools:,app:}
Example of of usage are
android:name="yourpackege.App"
tools:overrideLibrary="yourpackege.App"
app:showAsAction="never"
In the above examples attributes being
android:name, tools:overrideLibrary, app:showAsAction
Of course every single prefix has many more attributes for example
android:name,android:theme,android:value
Kindly note though that
The app namespace is not specific to a library, but it is used for all attributes defined in your app readhere
Just to test the explanation above if you remove lets say
xmlns:android="http://schemas.android.com/apk/res/android" and rebuild your android application, you will get and error that looks something like
So, I installed the latest SDK 21 Lollipop release. I was having the actionbar activated with icons on in, and I am trying to recover it back using the new toolbar feature... but it seems not working properly. Basically I am following the information provided here
Basically, you need to create a toolbar instance in the layout. So did I:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/myapp_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="20"
android:background="#drawable/action_bar_myapp" />
However, this is creating and error message at the second line with the error message "error: Error parsing XML unbound prefix".
When this error is happening (like in here) is usually due to having a wrong sintax, I copied/pasted directiyl from the webpage, also I made a simple test. By removing all android tags, the problem is still present.
Probably is something very simple, but I am stucked. Any idea?
You have to declare the android namespace.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
....
/>
I have a problem with this xml file as said in the title.
I dont know how to solve the problem as i have already searched a lot and only found answers like use clean or change validation of this type to ignore
none of the above worked as i want to clear this problem so that my R will be generet in the gen folder.
Hope someone can see the problem soon as this is my examprojekt im working on and cant get further without solving this error :)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Dekrypter" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/hello_world" />
</RelativeLayout>
Start your XML with:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE RelativeLayout>
The solution is to put on the top of xml this code. It identify the type of the document to encode!
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
Revalidate the project!
CIAO!!!
I retrieve a solution from a bug issue :
Click Window > Preferences > XML > XML Files > Validation
Change the setting 'validating files'>'No grammar specified' from warning to ignore.
Re-validate your project. No more warnings now.
It works for me.
Add
<?xml version="1.0" encoding="utf-8"?>
To the top of your XML file. This tells the parser that your file is indeed an XML, that it should use XML version 1.0, and that you are using utf-8 encoding.
Without it, the parser doesn't know how it should parse your XML.
First put this :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
and after that do this structure:
Click Window > Preferences > XML > XML Files > Validation
Change the setting 'validating files'>'No grammar specified' from warning to ignore.
Re-validate your project. No more warnings now.
thank you AntoineP and TecnoHelp83
https://stackoverflow.com/a/19314230/3117196
https://stackoverflow.com/a/22973854/3117196
worked as well
I have written a very simple accessibility service, the code works fine without an xml file defined for metadata but I want to add the xml file for compatibility purposes.
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service
xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeNotificationStateChanged"
android:notificationTimeout="100"
android:description=""
/>
However the error I'm getting is none of the 'android:' resources are defined and also I'm not allowed that description. Although the description happens regardless of what I type or in what string asset I prove.
Anyone have any ideas..
Here it says android 4.0 has the option to configure the accessibility service with xml. Are you using 4.0+?
Also it mentions certain configuration options like canRetrieveWindowContent are only available when using the XML configuration. Are you using such options? If not, I don't think you really need the XML configuration.
It needs the xmlns portion....
Thanks for the suggested solutions. Turns out that you need to have your target build at 14 for eclipse to accept that xml file.
I'm very new (second day!) to android and working my way through the dev guide. There, it says that you can reference attributes inside the current theme from your XML by using the form "?...", for example
<?xml version="1.0" encoding="utf-8"?>
<EditText id="text"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:textColor="?android:textDisabledColor"
android:text="#string/hello_world" />
If I try to build this, I just get "No resource found that matches the given name (at 'textColor' with value '?android:textDisabledColor')
Given that this seems pretty basic stuff, and yet I can't find any references to similar problems elsewhere, I must be missing something obvious or misunderstanding something simple. Can anyone tell me what it is?
I don't think textDisabledColor exists anymore - at least not in the newer SDKs which is probably why it can't be found. Try textColorSecondary instead - e.g.
android:textColor="?android:attr/android:textColorSecondary"
Unfortunately I cant figure out if theres a specific disabled color. I came across the site below which seems to define the default theme: See this link for definition of default theme
try android:textColor="?android:attr/textDisabledColor"