Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

what does the error multiple root tags mean

one of the errors on my Android Studio shows the error "multiple root tags" how do i fix it (the beginning (<) has the red squiggly line under it.):

< android.support.v4.view.ViewPager 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" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FunFactsActivity" TextView_android:text="@hello_world" />

1 Answer

This probably means the xml is not formatted properly, if you have a lot of code it might be less obvious where the issue is. Here is a simple example of what might cause this

.. top of your file <LinearLayout> ... layout content </LinearLayout> <LinearLayout> ...more content </LinearLayout>

You can only have 1 root layout and everything else goes inside, so the fix for this would be to move "more content" right under "layout content" and remove the last LinearLayout since a 2nd one is not allowed unless its inside the first