Jan-Peter Schmidt
Jan-Peter Schmidt

Reputation: 53

Android Studio org.xml.sax.SAXParseException in every project

I need help with an error in the AndroidStudio IDE. When I am opening an layout.xml file I get errors (called fatal IDE errors in error log). I attached a part of the error below. The error comes from the AndroidSupport plugin.

I have this problem in every project also in new created ones where no errors in the xml file exist. I tried reinstalling AndroidStudio, reinstalling Android SDK and now I am out of ideas what I can do further. Google doesnt help me. Is there anyone with the same problem? I also tried rebuilding, cleaning the project, invalidating the cache, restarting the computer and things like that.

I would be great if one could help me. Thanks in Advance. If you need more input please tell me!

Snippet from error log:

Error executing task com.android.tools.idea.uibuilder.editor.NlEditor$1@216a60b3: javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.] java.lang.RuntimeException: javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.] at com.android.tools.idea.uibuilder.palette.NlPaletteModel.loadPalette(NlPaletteModel.java:82) at com.android.tools.idea.uibuilder.palette.NlPaletteModel.getPalette(NlPaletteModel.java:60) at com.android.tools.idea.uibuilder.palette.NlPalettePanel.checkForNewMissingDependencies(NlPalettePanel.java:542) at com.android.tools.idea.uibuilder.palette.NlPalettePanel.setDesignSurface(NlPalettePanel.java:195) at com.android.tools.idea.uibuilder.palette.NlPalettePanel.(NlPalettePanel.java:140) at com.android.tools.idea.uibuilder.editor.NlPaletteManager.createContent(NlPaletteManager.java:88) at com.intellij.designer.LightToolWindowManager$4.run(LightToolWindowManager.java:261) at com.intellij.designer.LightToolWindowManager$4.run(LightToolWindowManager.java:258) at com.intellij.designer.LightToolWindowManager.bind(LightToolWindowManager.java:208) at com.android.tools.idea.uibuilder.editor.NlEditor$1.run(NlEditor.java:64) at com.intellij.openapi.project.DumbServiceImpl.notifyUpdateFinished(DumbServiceImpl.java:328) at com.intellij.openapi.project.DumbServiceImpl.access$1300(DumbServiceImpl.java:54) at com.intellij.openapi.project.DumbServiceImpl$4.run(DumbServiceImpl.java:306) at com.intellij.openapi.project.DumbPermissionServiceImpl.allowStartingDumbModeInside(DumbPermissionServiceImpl.java:37) at com.intellij.openapi.project.DumbService.allowStartingDumbModeInside(DumbService.java:283) at com.intellij.openapi.project.DumbServiceImpl.updateFinished(DumbServiceImpl.java:304) at com.intellij.openapi.project.DumbServiceImpl.access$1100(DumbServiceImpl.java:54) at com.intellij.openapi.project.DumbServiceImpl$12.run(DumbServiceImpl.java:516) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756) at java.awt.EventQueue.access$500(EventQueue.java:97) at java.awt.EventQueue$3.run(EventQueue.java:709) at java.awt.EventQueue$3.run(EventQueue.java:703) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:726) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:857) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:658) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) Caused by: javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.]

EDIT: XML File added Problem occurs in every XML File in res/layout folder. Drawable folder works fine! Here is an snippet from XML file:

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

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/imageView"
        android:layout_weight="0.9"
        android:contentDescription=""
        android:src="@drawable/logo_full"
        android:padding="20dp" />

Upvotes: 2

Views: 6244

Answers (3)

Jan-Peter Schmidt
Jan-Peter Schmidt

Reputation: 53

Finally I found the solution to this problem. I already tried reinstalling Android Studio and Android SDK. But what I have not seen is that there are more files from Android on disk that were not removed by the deinstallation routine. Deleting the AndroidStudio folder(s), the app folder and the workspace folder in C:/Users/NAME in combination with reinstalling Android Studio and the sdk fixed my problem. Thanks to all people that helped me!

Upvotes: 0

Charles Rousseau
Charles Rousseau

Reputation: 1

The error is "Content is not allowed in prolog" I had this issue with a xml i was building, the files was saved with in "utf8"

I found out I could save the file in "utf8 without BOM" (bytes order mark)

so basicly watch for any caracter (white space or BOM) before the xml tag in your layout.xml file.

Upvotes: 0

Moien.Dev
Moien.Dev

Reputation: 1058

Just Delete .idea directory and app.iml file and then import project again and it will generate new Gradle file

close Intellij idea

go to your workspace

deleting .idea folder

open your project and import it.

Upvotes: 0

Related Questions