Ahmed Nabil
Ahmed Nabil

Reputation: 751

Android resource compilation failed, ic_launcher_background.xml: error: file failed to compile

This error happened to me recently when I try to build any project,

Android resource compilation failed
E:\Android Projects\BarcodReader\app\src\main\res\drawable\ic_launcher_background.xml:12: error: not well-formed (invalid token).
E:\Android Projects\BarcodReader\app\src\main\res\drawable\ic_launcher_background.xml: error: file failed to compile.

and here's the file ic_launcher_background.xml

<component name="libraryTable">
    <library name="Gradle: junit:junit:4.12@jar">
        <CLASSES>
            <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar!/" />
        </CLASSES>
        <JAVADOC />
        <SOURCES>
            <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/a6c32b40bf3d76eca54e3c601e5d1470c86fcdfa/junit-4.12-sources.jar!/" />
        </SOURCES>
    </library>
</component>

when I hover over the file it shows this error

Attribute is missing the Android namespace prefix, Inspection info:Most Android views have attributes in the Android namespace. When referencing these attributes you must include the namespace prefix, or your attribute will be interpreted by aapt as just a custom attribute. Similarly, in manifest files, nearly all attributes should be in the android: namespace. Issue id: MissingPrefix

what might be causing this error?.

Upvotes: 0

Views: 5960

Answers (1)

Martin Zeitler
Martin Zeitler

Reputation: 76759

That ic_launcher_background.xml is a IDEA file and not an Android resource file.

Just replace it with whatever valid Android resource XML file and it should build.

Upvotes: 2

Related Questions