Dakshin
Dakshin

Reputation: 459

Android XML error: no resource identifier found for attribute 'xmlns' in package 'android'

I know there are a hundred questions here just like mine, but none of them seem to suit my specific problem, so I am asking a new question. Just in case this is a repeat, I'm sorry.

So, I am building an app, and the layout is causing me a few problems.
This is my XML code : (it's not yet complete)

  <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/toosl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical"
android:xmlns="http://schemas.android.com/apk/res/android" >

<TextView
    android:id="@+id/showNunmber"
    android:layout_width="wrap_content"
    android:layout_marginTop="15dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="number"
    android:textSize="30sp"/>

<TextView
    android:id="@+id/showAnswer"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="answer"
    android:layout_marginTop="35dp"
    android:layout_gravity="center"
    android:textSize="25sp"/>

 </LinearLayout>

The error that I'm getting is in the first line of the code where it says "error: no resource identifier found for attribute 'xmlns' in package 'android'

I've gone over and over the code, I've tried to refresh/rebuild the project, I tried deleting that particular line, etc.. and nothing seems to solve it.

So, if anyone has some ideas?

Thanks!

Upvotes: 2

Views: 14045

Answers (4)

Dakshin
Dakshin

Reputation: 459

I found my mistake, it's in the last attribute of my first LinearLayout tag.

I should not have included that line at the bottom.
I removed that line and now its working.

Thank you!

Upvotes: 1

aladdin harb
aladdin harb

Reputation: 1

if none of the above worked make sure you add this: compile 'com.android.support:percent:23.1.1'

to your build.gradle

Upvotes: 0

Mayank Saini
Mayank Saini

Reputation: 3017

Replace it with this

  <LinearLayout 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:layout_gravity="center"
    android:orientation="vertical"
    >

    <TextView
        android:id="@+id/showNunmber"
        android:layout_width="wrap_content"
        android:layout_marginTop="15dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="number"
        android:textSize="30sp"/>

    <TextView
        android:id="@+id/showAnswer"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:text="answer"
        android:layout_marginTop="35dp"
        android:layout_gravity="center"
        android:textSize="25sp"/>

     </LinearLayout>

Upvotes: 1

Giru Bhai
Giru Bhai

Reputation: 14398

Remove

android:xmlns="http://schemas.android.com/apk/res/android"

from your layout,i.e. use your layout as

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/toosl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="vertical">

<TextView
    android:id="@+id/showNunmber"
    android:layout_width="wrap_content"
    android:layout_marginTop="15dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="number"
    android:textSize="30sp"/>

<TextView
    android:id="@+id/showAnswer"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="answer"
    android:layout_marginTop="35dp"
    android:layout_gravity="center"
    android:textSize="25sp"/>

 </LinearLayout>

Upvotes: 2

Related Questions