104

I work in Intellij IDEA, but my computer freezes so I turn off my computer. (long click power button) When I turned on computer and start IntelliJ IDEA I had this error:

Cannot load settings from file 'C:\Users\user\.IdeaIC13\config\options\code.style.schemes.xml': java.lang.AssertionError: Unexpected content storage modification File content will be recreated

I close IDEA and start again, now I don't have the previous error, but when I open my project I have this error:

Error:Internal error: (org.jdom.input.JDOMParseException) Error on line 1: Content is not allowed in prolog.
org.jdom.input.JDOMParseException: Error on line 1: Content is not allowed in prolog.
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:533)
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:946)
    at com.intellij.openapi.util.JDOMUtil.loadDocument(JDOMUtil.java:364)
    at com.intellij.openapi.util.JDOMUtil.loadDocument(JDOMUtil.java:342)
    at org.jetbrains.jps.model.serialization.JpsLoaderBase.loadRootElement(JpsLoaderBase.java:69)
    at org.jetbrains.jps.model.serialization.JpsLoaderBase.loadRootElement(JpsLoaderBase.java:40)
    at org.jetbrains.jps.model.serialization.JpsLoaderBase.loadComponents(JpsLoaderBase.java:52)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadFromDirectory(JpsProjectLoader.java:119)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadProject(JpsProjectLoader.java:98)
    at org.jetbrains.jps.model.serialization.impl.JpsSerializationManagerImpl.loadModel(JpsSerializationManagerImpl.java:41)
    at org.jetbrains.jps.cmdline.JpsModelLoaderImpl.loadModel(JpsModelLoaderImpl.java:45)
    at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:71)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:198)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:113)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:133)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1436)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:999)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518)
    ... 20 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1436)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:999)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:518)
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:946)
    at com.intellij.openapi.util.JDOMUtil.loadDocument(JDOMUtil.java:364)
    at com.intellij.openapi.util.JDOMUtil.loadDocument(JDOMUtil.java:342)
    at org.jetbrains.jps.model.serialization.JpsLoaderBase.loadRootElement(JpsLoaderBase.java:69)
    at org.jetbrains.jps.model.serialization.JpsLoaderBase.loadRootElement(JpsLoaderBase.java:40)
    at org.jetbrains.jps.model.serialization.JpsLoaderBase.loadComponents(JpsLoaderBase.java:52)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadFromDirectory(JpsProjectLoader.java:119)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadProject(JpsProjectLoader.java:98)
    at org.jetbrains.jps.model.serialization.impl.JpsSerializationManagerImpl.loadModel(JpsSerializationManagerImpl.java:41)
    at org.jetbrains.jps.cmdline.JpsModelLoaderImpl.loadModel(JpsModelLoaderImpl.java:45)
    at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:71)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:198)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:113)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:133)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

How can I fix this problem?

Community
  • 1
  • 1
bvv
  • 1,893
  • 3
  • 14
  • 16
  • Check the encoding on the XML file. The error suggests that it is the result of [bad encoding](http://stackoverflow.com/q/4569123/1079354) - namely, a byte-order mark being where it shouldn't be. – Makoto Oct 06 '14 at 07:35
  • This problem happens in Android Studio when it tries to force-check for new SDK versions upon launch. There is absolutely nothing one can do to fix it. – IgorGanapolsky Aug 18 '15 at 20:31

11 Answers11

209

This answer works for both IntelliJ & AndroidStudio

If you cannot even open your project in IntelliJ[AndroidStudio]:

  • Close IntelliJ[AndroidStudio]
  • Go to the directory <your_home>/.IntelliJIdeaXX[.AndroidStudioXX]/system/cache

    WHERE

    • <your_home> is

      • Windows Users: C:\Users\<**Your User**>\ (or %USERPROFILE%)
      • Linux Users(Ubuntu), Mac: ~/
    • XX is your IntelliJ version (This directory is "caches" in some versions.)

  • Remove all the files in the cache directory.
  • Then restart IntelliJ[AndroidStudio]

This has worked for me in the past.

CJBS
  • 15,147
  • 6
  • 86
  • 135
Ask613
  • 2,775
  • 1
  • 19
  • 27
  • 3
    What is home? The workspace where the projects are located? Android Studio in program files/Android/? or the Android Studio folder in Users/UserName/AndroidStudio? – Andrew S Feb 06 '15 at 04:24
  • 2
    It depends on the OS you are using. For example a user's default home directory in Windows 7 is c:\Users\. For Linux run "echo $HOME" – Ask613 Feb 06 '15 at 14:48
  • This surely works, but be aware that this will reset your settings (fonts, formatting settings etc) in your Intellij. Fortunately, you can easily get them back in settings since when you first change these settings you had to create a scheme and that scheme still exists. – NecipAllef Sep 23 '15 at 03:18
  • In idea 13, the "cache" directory is now "caches" - removing everything in there still works. – Yann Nov 06 '15 at 14:35
  • That folder does not contain it. [macbook_tcs ] ---> [/Users/timsiwula/]$ cd ~/.IntelliJIdea15/ [macbook_tcs ] ---> [/Users/timsiwula/.IntelliJIdea15/]$ ls -la total 0 drwxr-xr-x 3 timsiwula staff 102 Jun 12 10:57 . drwxr-xr-x+ 105 timsiwula staff 3570 Nov 6 23:47 .. drwxr-xr-x 3 timsiwula staff 102 Oct 7 22:37 restart [macbook_tcs ] ---> [/Users/timsiwula/.IntelliJIdea15/]$ – Tim Siwula Nov 10 '16 at 23:08
69

my solution

In project/.idea I have broken workspace.xml file. I just close Android Studio (Intellij IDEA), remove this file and start Android Studio.

All other approaches not work for me.

ViT-Vetal-
  • 2,431
  • 3
  • 19
  • 35
23

Try File -> Invalidate Caches / Restart ...

Igor Konoplyanko
  • 9,176
  • 6
  • 57
  • 100
12

I had the same problem, I removed the .idea directory and *.iml files and created the project again.

Hossein
  • 1,151
  • 9
  • 19
2
  1. In .idea folder, many XML files are present.

  2. This error comes if some XML files are invalid.

  3. First check workspace.xml file is valid or not.

  4. If workspace.xml file is valid then check other file's.

user229044
  • 232,980
  • 40
  • 330
  • 338
Ravi Macha
  • 687
  • 8
  • 5
2

In my case, the project files under .idea got corrupted. If you have the project files checked in SVN or saved somewhere just remove all the local changes and revert to the previous working copy . Also rebuild the cache by File --> Invalidate Cache.

After that it is fixed for me. The "Error:Internal error: (org.jdom.input.JDOMParseException) " went away.

Tony
  • 1,458
  • 2
  • 11
  • 13
1

I had the same problem when Windows crashed while Android Studio was on. I followed the following steps :-

  • Close Android Studio
  • Delete the .idea directory outside the project folder. Note : Do not delete the .idea directory inside the project folder. The .idea directory which you have to delete will contain some .iml files.
  • Restart Android Studio
  • tadaaa!!
  • Deval Khandelwal
    • 3,458
    • 1
    • 27
    • 38
    1

    I've found on several occasions that "Content is not allowed in prolog" presented when I had an XML file with leading spaces in front of the xml or doc type declarations at the start of the file.

    I had the same symptoms, and was able to solve by closing the project and going through each of the XML files in the project ".idea" folder. In my case, I found that somehow a few hundred lines of leading whitespace had been added to the "workspace.xml" file. I removed the leading whitespace from the file, restarted IDEa and everything worked again.

    gbegley
    • 2,609
    • 5
    • 29
    • 41
    1

    In my case nothing of these worked.

    But the final solution was very easy:

     rm -r ~/Library/Preferences/AndroidStudio[X.X]/codestyles/
    
    goRGon
    • 4,402
    • 2
    • 43
    • 45
    0

    If you are using a version control system like github, the easiest way is to erase your project folder, open IntelliJ and clone your repository again. Whatever file is corrupted is going to be gone and it should work fine again.

    0

    If your error happens when the IntelliJ idea starting. Just give a restart for the laptop. It will go after restarting. For me, this error happens per year like that.

    Supun Sandaruwan
    • 1,814
    • 19
    • 19