Error:(1) Error parsing XML: not well-formed (invalid token)

4.4k Views Asked by At

On right clicking the error "Error:(1) Error parsing XML: not well-formed (invalid token)" and then jump to source it opens the following activity_main.xml. I am not able to figure the error out

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    tools:context="com.example.utkarsh.beatle.app.MainActivity"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="MergeRootFrame"/>

Andoridmanifest.xml

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.utkarsh.beatle.app" >

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

fragment_main.xml

<FrameLayout 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="com.example.utkarsh.beatle.app.MainActivity$PlaceholderFragment">

<ListView  android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/list_view_forecast" />

</FrameLayout>

activity_main.xml

<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
tools:context="com.example.utkarsh.beatle.app.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MergeRootFrame"/>

list_item_forecast.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:id="@+id/list_item_forecast_textview"/>
1

There are 1 best solutions below

0
On BEST ANSWER

Changing from FrameLayout to RelativeLayout in activity_main.xml solved the error, but I don't know how it worked and whats wrong in FrameLayout. But I got stuck to my previous problem , again I am getting no error messages but My app doesn't show any ListView when i run it on my device ,blank white screen with app name written on top appears on clicking the app icon in my device. Others who are having the same problem please help me and please check whether changing to RelativeLayout works or not.