This question already has answers here:
Android Studio shows wrong file contents
(10 answers)
Closed 3 years ago.
Once I create a new project I get an error
C:\Users\User\Desktop\4Find\app\src\main\res\values\colors.xml:9:18: Error: XML document structures must start and end within the same entity.
My colours.xml file at default looks as below;
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidLayouts">
<shared>
<config />
</shared>
</component>
<component name="AndroidLogFilters">
<option n
I faced this problem before. Instead of reinstall it, what i did was delete AndroidStudio file which located at C:\Users\YourUserName\.AndroidStudio3.2 (.AndroidStudio file name should depends on your android studio version). This will reset android studio to default setting.
Hope this could help you.
colors.xml should be look like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#17AC82</color>
<color name="colorPrimaryDark">#17AC82</color>
<color name="colorAccent">#17AC82</color>
...........
</resources>
Something went wrong. It's not how colors.xml should look like, it's even not valid XML.
You can edit colors.xml but in my experience project will have other issues in its resources.
Try to create new project one more time.
Delete Android Studio file which located at
C:\Users\YourUserName\.AndroidStudio(version)
Related
So I updated my Android Studio to v3.2. When I tried compiling the project, build fails.
Below is the error:
Android resource compilation failed
Output: C:\Users\Ashish\AndroidStudioProjects\StartUp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:900: error: <item> inner element must either be a resource reference or empty.
Command: C:\Users\Ashish\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\7f1fbe9171e916e5044000cd76b749c8\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy \
-o \
C:\Users\Ashish\AndroidStudioProjects\StartUp\app\build\intermediates\res\merged\debug \
C:\Users\Ashish\AndroidStudioProjects\StartUp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
Please do tell if there is any more information required. Any help will be appreciated.
I was facing this issue today after updating gradle from 3.1.4 to 3.2.0. I don't know why, but the build started to throw that exception. i deleted the build folder, and deleted the gradle caches folder but nothing worked, so i looked at the merged values.xml and turns out that my ids.xml was defining a wrong id that was being merged to the values.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="downloading_package" type="id">Baixando pacote de sincronização</item>
</resources>
And apparently this was working before the update... for my case i deleted the ids.xml file (it was useless in the project)
I wish i could know why before the update everything was working
the <item> in values.xml at line 900 ...might be of resource-type id.
the correct syntax would be (just as the error message tells):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="id_name" />
</resources>
see the documentation.
For me I had the layout width and layout height in the layout view and the LinearLayout view for databinding. This threw a duplicate error.
I fixed this by removing the layout_width and layout_height attributes in <layout>.
I'm just finishing this issue a few minutes ago, try to modify or delete id.xml, if you think you don't have it, try to find in another module in your app. I change my value resource from <item name="header_view" type="id">header_view</item> to <item name="header_view" type="id"/> and it worked for me.
just change your attr name which is present in resource -> values -> attr
<attr name="fontFamilys">
<enum name="roboto" value="0" />
<enum name="roboto_condensed" value="1" />
<enum name="roboto_slab" value="2" />
</attr>
for example if you are getting error related to fontFamily just change the the name build the application error will not come
i also meet the problem,you just need to find where the values in,and update it from <item type="id" name="id_name" >id_name</item> to <item type="id" name="id_name" />,now it's ok.
I got that problem when I'd quotation within <string> tag
<string name="vj_dialogue">I'm waiting</string>
when I escaped it with backslash '' . The problem was gone
<string name="vj_dialogue">I\'m waiting</string>
This could also happen if you mistakenly happened to not escape some value (apostrophe with backslash or ampersand with & or something else I am not aware of) under res/values/strings.xml file
to bring it in context here is an example ->
incorrect :
<string name="update_now">Let's Update now</string>
correct :
<string name="update_now">Let\'s Update now</string>
in your build gradle(Project:name) do it like that
classpath 'com.android.tools.build:gradle:3.+'
then rebuild your project .. after that it will show message to update your gradle from 4.6 to 4.10
In my case
<?xml version="1.0" encoding="utf-8"?>
is repeated twice in the XML. Make sure it should be one per a file at the top of the XML.
This is what worked for me:
In my build.gradle file > dependencies, I was implementing a newer version of appcompat library
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:21.0.3'
implementation 'com.android.support:appcompat-v7:21.0.3'
implementation 'androidx.appcompat:appcompat:1.0.2'}
After commenting //implementation 'androidx.appcompat:appcompat:1.0.2' It worked fine. I would suggest, even if it's a different library, Please check the version you are using.
In your xml file, you may forget to add /> to brace your attribute.
i am using from android Studio but i don't know problem. so i searched in stack overflow but not useful ...
please Help ...
Error color.xml
I:\New folder\app\src\main\res\values\colors.xml:1:1: Error: Content
is not allowed in prolog.
it looks like the content in color.xml was not in proper as usual format . the content in the auto generated color.xml file has colors value fore project.
for fix,copy and paste this code in color.xml file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
</resources>
if the contnet in the color.xml file is always gone like this whenever you create new android studio project ,then fix will be :-
1)click on new file, Invalidate Cache/Restart
if not then reinstall android studio
How can I solve this error?
C:\Users\spark\AndroidStudioProject\MyApplication\app\src\main\res\values\colors.xml:4:101: Error: XML document structures must start and end in the same entity
<component name="libraryTable">
<library name="Gradle: com.android.support:customview-28.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/customview-28.0.0.aar
So, the error that you put in the comments is for the colors.xml file. And that file shouldn't contain <component> tags, or refer to Gradle stuff.
For example, should look like so
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
</resources>
I don't think Android Studio is the problem here, but if you think it is, I suggest you use a different version of Android Studio.
XML document structures must start and end within the same entity.
So I updated my Android Studio to v3.2. When I tried compiling the project, build fails.
Below is the error:
Android resource compilation failed
Output: C:\Users\Ashish\AndroidStudioProjects\StartUp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:900: error: <item> inner element must either be a resource reference or empty.
Command: C:\Users\Ashish\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\7f1fbe9171e916e5044000cd76b749c8\aapt2-3.2.0-4818971-windows\aapt2.exe compile --legacy \
-o \
C:\Users\Ashish\AndroidStudioProjects\StartUp\app\build\intermediates\res\merged\debug \
C:\Users\Ashish\AndroidStudioProjects\StartUp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
Please do tell if there is any more information required. Any help will be appreciated.
I was facing this issue today after updating gradle from 3.1.4 to 3.2.0. I don't know why, but the build started to throw that exception. i deleted the build folder, and deleted the gradle caches folder but nothing worked, so i looked at the merged values.xml and turns out that my ids.xml was defining a wrong id that was being merged to the values.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="downloading_package" type="id">Baixando pacote de sincronização</item>
</resources>
And apparently this was working before the update... for my case i deleted the ids.xml file (it was useless in the project)
I wish i could know why before the update everything was working
the <item> in values.xml at line 900 ...might be of resource-type id.
the correct syntax would be (just as the error message tells):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="id_name" />
</resources>
see the documentation.
For me I had the layout width and layout height in the layout view and the LinearLayout view for databinding. This threw a duplicate error.
I fixed this by removing the layout_width and layout_height attributes in <layout>.
I'm just finishing this issue a few minutes ago, try to modify or delete id.xml, if you think you don't have it, try to find in another module in your app. I change my value resource from <item name="header_view" type="id">header_view</item> to <item name="header_view" type="id"/> and it worked for me.
just change your attr name which is present in resource -> values -> attr
<attr name="fontFamilys">
<enum name="roboto" value="0" />
<enum name="roboto_condensed" value="1" />
<enum name="roboto_slab" value="2" />
</attr>
for example if you are getting error related to fontFamily just change the the name build the application error will not come
i also meet the problem,you just need to find where the values in,and update it from <item type="id" name="id_name" >id_name</item> to <item type="id" name="id_name" />,now it's ok.
I got that problem when I'd quotation within <string> tag
<string name="vj_dialogue">I'm waiting</string>
when I escaped it with backslash '' . The problem was gone
<string name="vj_dialogue">I\'m waiting</string>
This could also happen if you mistakenly happened to not escape some value (apostrophe with backslash or ampersand with & or something else I am not aware of) under res/values/strings.xml file
to bring it in context here is an example ->
incorrect :
<string name="update_now">Let's Update now</string>
correct :
<string name="update_now">Let\'s Update now</string>
in your build gradle(Project:name) do it like that
classpath 'com.android.tools.build:gradle:3.+'
then rebuild your project .. after that it will show message to update your gradle from 4.6 to 4.10
In my case
<?xml version="1.0" encoding="utf-8"?>
is repeated twice in the XML. Make sure it should be one per a file at the top of the XML.
This is what worked for me:
In my build.gradle file > dependencies, I was implementing a newer version of appcompat library
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:21.0.3'
implementation 'com.android.support:appcompat-v7:21.0.3'
implementation 'androidx.appcompat:appcompat:1.0.2'}
After commenting //implementation 'androidx.appcompat:appcompat:1.0.2' It worked fine. I would suggest, even if it's a different library, Please check the version you are using.
In your xml file, you may forget to add /> to brace your attribute.
The issue is:
I have a project A. It runs well.
Then I config A as a library project. And new a project B to use it.
Then the issue comes like followings:
\res\layout\taskslist.xml:18: error: No resource identifier found for attribute 'content' in package 'com.XXX'
The attribute named 'content' is defined in XML used by MultiDirectionSlidingDrawer in project A:
<resources>
<declare-styleable name="MultiDirectionSlidingDrawer">
<attr name="content" format="reference" />
</declare-styleable>
</resources>
And the taskslist.xml looks like:
<com.XXX.util.MultiDirectionSlidingDrawer
xmlns:my="http://schemas.android.com/apk/res/com.XXX"
...
my:content="#id/content">
<include
android:id="#+id/content"
layout="#layout/menuwithll" />
<ImageView
android:id="#+id/handle"
... />
</com.XXX.util.MultiDirectionSlidingDrawer>
Actually I look into R.java in project A. There is an attr named "content" likes:
public static final class attr {
public static int content=0x7f010002;
}
Anyone know this issue? Thanks in advance!!!
BTW. I have tried clean project. And config project B both in "Android" and "Java build path".
For later one's who also has this issue. It's really simple to resolve by add following code in you layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:my="http://schemas.android.com/apk/res-auto"