1

So I just finished creating a new UI in DroidDraw (relativelayout throughout), and I've imported it into my main.xml file. The problem is, whenever I run "check for xml errors" the output return states "cvc-elt.1: Cannot find the declaration of element 'RelativeLayout'. [8]" It's really bothersome, and I think it's what's causing my app to force close on run (there are no errors in the actual code itself). I'm fairly new to the whole android dev scene, so it's entirely likely that this is supposed to happen and I'm just being stupid. In any case, here is the block of text in which the error is returned:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  android:id="@+id/widget31"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android">
</RelativeLayout>

Any help would be much obliged.

3
  • Welcome to StackOverflow! You can indeed include <> in code snippets. Check out the editing help: stackoverflow.com/editing-help -- you can always quickly find this while editing by clicking the orange-backgrounded question mark at the upper-right of an edit box. Commented Oct 2, 2011 at 1:54
  • You're missing a closing / or end tag </RelativeLayout>. Based on the error I'm thinking that's not the problem, but you should fix that in your question so that we can start looking for the real issue.
    – Doug Paul
    Commented Oct 2, 2011 at 2:02
  • @DougPaul Thanks, forgot to include it... Although I do have other code between the first declaration and the end tag.
    – user966126
    Commented Oct 2, 2011 at 2:08

1 Answer 1

1

Yeah, I don't believe any of the tag names are actually declared. Notice that you're importing the Android namespace as android, so things prefixed with android: are declared. Anything that's not prefixed with android: isn't really being declared. This isn't a problem. Some would say it's a little sloppy of Google, since the XML won't validate, but the Android compiler doesn't have a problem with it.

So I think you need do start looking elsewhere for the reason your app crashes on startup. (Are you developing in Eclipse? Run in debug mode and/or watch LogCat.)

Incidentally, the reason that the element names aren't declared is because you can use your own. For example, if you write your own subclass of Button with the fully qualified name com.mydomain.MyAmazingButton, you can use it in your layouts like this:

<com.mydomain.MyAmazingButton android:layout_width="..." android:layout_height="..." />

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.