23

If I create a new XML-file (using the default Android Studio "Create Linear Layout"), Studio makes a file with content:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> </LinearLayout> 

If I (right)-click "Analyze... → Inspect Code" the result window throws 2 times: "Namespace is not bound" and references to line 3 and 7 (the LinearLayout-tags). Is it a bug in Studio?

1
  • I'm seeing this in IntelliJ IDEA 12 as well. Commented Oct 11, 2013 at 8:52

5 Answers 5

34

If you get the error:

Namespace 'tools' is not bound:

Example:

<activity android:name="com.google.android.gms.ads.AdActivity" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" tools:replace="android:theme" /> 

Add xmlns:tools="http://schemas.android.com/tools" at the top of the manifest (or activity).

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mypackage" xmlns:tools="http://schemas.android.com/tools"> 
Sign up to request clarification or add additional context in comments.

1 Comment

this didn't work adding it in the Manifest but it worked when I added it to the Activity XML file. Thanks!
5

You must copy everything except the first line <?xml version="1.0" encoding="utf-8"?> from your xml file, create a new xml layout file and erase everything but the first line, then paste the copied content into the new file below the first line. Then you use the new layout file instead of the old one.

Note: This is just my interpretation of leo's answer, I don't know if it works or not and cannot test it because I don't have the same problem as you guys.

2 Comments

A snippet showing the correctly formatted XML file would have been easier to understand instead of that riddle you described =)
That's true, but as I noted I didn't have the same issue as them, I just translated the unintelligible answer of someone else.
4

try this: in android studio 2.2.3 press F2 to jump between the warning then press Alt+Enter; this created the following reference: xmlns:app="http://schemas.android.com/apk/res-auto" and fixed the issue. Moreover, I checked my XML files and all have this encoding version: ?xml version="1.0" encoding="utf-8"?

Comments

3

I just added in the xml on the root widget this line:

xmlns:tools="http://schemas.android.com/tools" 

An example of this is:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_height="match_parent" android:layout_width="match_parent"> 

then you can use attributes like:

tools:text="+52" 

Comments

2

Add:

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

to yor manifest tag

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.