'Unexpected namespace prefix "app"' in Android wear module
Asked Answered
E

1

5

I added a new android wear module based on this Google doc

but I am getting the error described in the title. Here is my layout.

<?xml version="1.0" encoding="utf-8"?>
<android.support.wear.widget.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/dark_grey"
    android:padding="@dimen/box_inset_layout_padding"
    tools:context=".MainWearActivity"
    tools:deviceIds="wear">  

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="@dimen/inner_frame_layout_padding"
        app:boxedEdges="all">  <---this is the offending line 

        <android.support.v7.widget.AppCompatTextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/hello_world" />

    </FrameLayout>
</android.support.wear.widget.BoxInsetLayout>

Anyone know what's going on? I appreciate explanation as to why I am getting this error. UPDATE: I removed the redundant android prefix. Android studio requires me to change the app prefix to change to android but even after doing so the error remains. Is it safe time to assume it is a bug?

Eudemonia answered 7/12, 2018 at 22:4 Comment(10)
Hmm, that's odd. It's specifically pointing to an attribute with the tools prefix, but it's complaining about app? You have the xmlns:android="http://schemas.android.com/apk/res/android" declaration there twice. Try removing one of those, and see if that was the issue.Bradney
@Mike M, please see the update.Eudemonia
Dunno. Is it still the same error message?Bradney
@Mike M, I screwed up. The error was and is at the app:boxededges and not at tools. I have corrected it now. Sorry for wasting your time. I was in a hurry to go home and made that mistake.Eudemonia
That makes more sense. I'm assuming that attribute is actually used by the BoxInsetLayout to apply some sort of visual effect to that child. Android Studio might just be confused because it's on a non-support library View. Is it just a warning? Can you suppress it? Put your cursor on that line, hit alt-enter, and see if there's a "Suppress..." option in the pop-up menu.Bradney
Wait, did I misunderstand? Do you mean you've fixed the issue?Bradney
No, I meant I corrected my question. I suppressed the error but I am getting the following when I run it on the emulator. Caused by: android.view.InflateException: Binary XML file line #19: Binary XML file line #19: Error inflating class androidEudemonia
We'd need to see the complete stack trace.Bradney
The error I mentioned right before this comment was caused by the the AppCompatTextView. I simply changed it to regular textview and it compiles fine. If you make your comment an answer I will accept it as an answer so others can learn from it.Eudemonia
Oh, it's cool. Just a quick suggestion. Nothing major. Please feel free to post an answer of your own that explains how to access that menu, and what exactly that Suppress option added to your layout to get rid of the warning. I don't actually know. :-) Thank you, though. I appreciate the offer. Glad you got it working. Cheers!Bradney
E
8

Based on what Mike M suggested, I right clicked on the error and I selected suppress in Android studio. My Framelayout now looks like this. I do not however currently know what caused the warning.

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="@dimen/inner_frame_layout_padding"
        app:boxedEdges="all"
        tools:ignore="MissingPrefix">

This seems to work for now.

Eudemonia answered 8/12, 2018 at 19:23 Comment(2)
I still get this all the time. This bandaid works, but I would have thought it would be resolved by this point.Eyehole
Very interesting. I followed documentation and used app:layout_boxedEdges="all", but it raises compile time error. app:boxedEdges="all" shows red, but when I suppress as per your solution, it's working magically. It's 2021 and still the same!Hortense

© 2022 - 2024 — McMap. All rights reserved.