Failed to parse XML file for android

error: failed to parse xml android manifest
android studio failed to parse xml in manifest
please ensure that the android manifest is a valid xml document and try again
gradle sync failed to parse xml
failed to parse xml gradle
failed to parse xml resource file android studio
failed to parse the xml document
message: expected start or end tag affected modules: app

I am basically brand new to this and working through an example in a book. my button1.xml looks like this....

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" 
        android:drawable="@drawable/buttonpressed" />
    <item android:state_focused="true" 
        android:drawable="@drawable/buttonfocused" />
    <item android:drawable="@drawable/buttonnormal" />
</selector>

Main.xml...

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

    <ImageButton
        android:id="@+id/button_one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="5px"
        android:src="@drawable/button1">
    </ImageButton>

</LinearLayout>

and I keep getting this error

eclipse.buildId=M20110909-1335
java.version=1.7.0_01
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64

Error
Tue Oct 25 12:19:07 CDT 2011
main.xml: Failed to parse file C:\Users\kpreese\workspace\Chapter7\res\drawable\button1.xml

org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: <item> tag requires a 'drawable' attribute or child tag defining a drawable
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:178)
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:832)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:769)
    at com.android.layoutlib.bridge.impl.ResourceHelper.getDrawable(ResourceHelper.java:208)
    at com.android.layoutlib.bridge.android.BridgeTypedArray.getDrawable(BridgeTypedArray.java:775)
    at android.widget.ImageView.<init>(ImageView.java:118)
    at android.widget.ImageButton.<init>(ImageButton.java:85)
    at android.widget.ImageButton.<init>(ImageButton.java:81)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at android.view.LayoutInflater.createView(LayoutInflater.java:576)
    at com.android.layoutlib.bridge.android.BridgeInflater.onCreateView(BridgeInflater.java:84)
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
    at com.android.layoutlib.bridge.android.BridgeInflater.createViewFromTag(BridgeInflater.java:129)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:83)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:702)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:367)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:321)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:372)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1317)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1071)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$ConfigListener.onConfigurationChange(GraphicalEditorPart.java:493)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.onTargetChange(GraphicalEditorPart.java:973)
    at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.onDescriptorsChanged(LayoutEditor.java:568)
    at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.initUiRootNode(LayoutEditor.java:490)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$TargetListener.updateEditor(GraphicalEditorPart.java:787)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart$TargetListener.onTargetLoaded(GraphicalEditorPart.java:752)
    at com.android.ide.eclipse.adt.AdtPlugin$11.run(AdtPlugin.java:1613)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

I can't seem to figure this out. I searched and found many similar problems, but didn't find any of the errors myself. Any suggestions?

-- I did try switching two of the files (buttonpressed and buttonfocused) and still received the error at the same line of code. Then replaced all of the files with the ic_launcher file, this also resulted in the same error. If I set the android.src="#00000000" it does work. I don't know if this helps but seems to indicate the problem is not the files but in the button1.xml code.

so I got it fixed I think. I am not really sure what I did but retype the android:src="@drawable/button1"> line. and poof it works. Thank you both for your help!

I had the same issue. In my case there was a single space before the xml tag in the XML file (the source copied from the android developers web page) After I removed the space and readd the imagebutton everything went normal. I tried to reinsert the space and got the same error again.

Failed to parse XML file for android, I had the same issue. In my case there was a single space before the xml tag in the XML file (the source copied from the android developers web page) After I� Android XML failed to parse. Ask Question Asked 5 years, 6 months ago. Active 5 years, 6 months ago. Viewed 662 times 1. Failed to parse file C:\Programming

Change

<ImageButton
        android:id="@+id/button_one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="5px"
        android:src="@drawable/button1">

to

<ImageButton
        android:id="@+id/button_one"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingTop="5px"
        android:background="@drawable/button1">

Notice that android:src="@drawable/button1" is changed to android:background="@drawable/button1"

how to fix 'ERROR: Failed to parse XML in AndroidManifest.xml' in , I'm working on android studio project. and i need to fix 'Failed to parse XML' error in my manifest file. It was working normally since 2 days, and� pls add this to gradle file " implementation 'com.android.support:design:28.0.0' " --- and pls check styles and fields in xml once and SYNC – satyan_android Feb 13 '19 at 5:23 @satyan_android If the author don't use that lib, why would he add this dependency?

If you are using ADT 14 with android 4.0 sdk there is an issue ( http://code.google.com/p/android/issues/detail?id=21046 ) related to statelist drawables.

A temporary solution there would be to start eclipse with parameter -clean ( some other guy reports that this did not help, though). But you can give it a try.

AndroidManifest.xml parsing error (SOLVED) - Questions, Failed building Android resources to R.java: \AndroidManifest.xml:29: error: Error parsing XML: not well-formed (invalid token) I get this error The AndroidManifest.xml file for my game has a 0x00 character in some way. Re: Failed to parse XML file This is because you've got the preview window open in Creo Parametric when you go to import the XML. If you close the preview window before you select the XML you won't get this error.

Cleaning the project and restarting Eclipse worked for me..

Parse XML data, This lesson explains how to parse XML documents and use their data. To learn more about creating web-based content in your Android app,� Failed to parse setup.xml – Intel Software Installer error. If you have downloaded a newer version of an Intel driver and are trying to install it on your Windows 10 system in order to update the driver, the Intel software installer generates an error message Unable to parse setup.xml, this post may be able to guide you.

Go to Build-> Clean project and Rebuild project. It works ...

XML Parsing Error on AndroidManifest.xml � Issue #116 � getsentry , XML Parsing Error on AndroidManifest.xml #116 But once Sentry Android plugin was active it failed to build with mentioned error - however� We recommend XmlPullParser, which is an efficient and maintainable way to parse XML on Android. Historically Android has had two implementations of this interface: KXmlParser via XmlPullParserFactory.newPullParser (). ExpatPullParser, via Xml.newPullParser ().

Resolved Error "parsing XML XML or text declaration not at start of , Resolved Error "parsing XML XML or text declaration not at start of entity" some times we Duration: 2:20 Posted: Aug 5, 2018 Find the “Core Settings” block and click on Settings. The “Core Settings” block looks like this: After that, you will see the details of your Parse app, such as your App Id and your Client Key. Copy these credentials and paste them in the appropriate place at the strings.xml file of your Android Studio Project.

Failed to parse XML file for android, Failed to parse XML file for android, Programmer Sought, the best programmer technical posts sharing site. The next step involves specifying the file for XmlPullParser that contains XML. It could be a file or could be a Stream. In our case it is a stream.Its syntax is given below − myparser.setInput(stream, null); The last step is to parse the XML. An XML file consist of events, Name, Text, AttributesValue e.t.c.

Zebra Enterprise Connector fails to parse XML Report, If ZEC is reporting an XML parsing error and failing to send print jobs, consider the XSL file that will help ZEC transform the file to the appropriate format. Android provides a rich set of APIs to work with XML documents in your Android app. Learn PHP for free! Make the leap into server-side programming with a comprehensive cover of PHP & MySQL.

Comments
  • It looks like @drawable/buttonpressed can't be found. Are you sure it's there?
  • Thanks for the quick reply! Yes the file is there. I have updated the package several times and the file shows up in the explorer. I created all three of the image files in gimp and saved them the same so I would assume if two work, the other one should...... hmmmmm....
  • possible duplicate of Valid XML file gives "failed to parse" error in Android ADT
  • Am I the only one who can't see a difference between these two?
  • Look at the last line of them. android:src="..." is changed to android:background="..." . I changed my post to be more clear
  • Thanks for the quick reply. I changed src to background and the same error came up though.