Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build time error: content is not allowed in prolog

I am not able to build. I know the error is in jdkAnnotations.jar. I reinstalled android studio, but the problem persists. It also says no IDEA annotations attached in jdk 1.8. Should i reinstall jdk 1.8 also? i am clicking on the button that says attach annotations but nothing is happening. Please help. And why is this problem happening? is there something wrong in any xml resource file or what?

C:/Program Files/Android/Android Studio/lib/jdkAnnotations.jar!/java/awt/event/annotations.xml: Content is not allowed in prolog.
    org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
like image 514
Cassius Avatar asked Oct 04 '18 05:10

Cassius


2 Answers

I got the same error today. Just reinstalling Android Studio did not help. The following steps worked for me:

  1. Close Android Studio
  2. Go to C:\Users\Username
  3. Delete the whole folders: ".AndroidStudioX.X" and ".gradle"
  4. Start Android Studio

Now all the Settings will be reinstalled and you can work on with your project

like image 192
AndroidDev Avatar answered Nov 03 '22 01:11

AndroidDev


Had the same problem, it seems like others stated, a BOM problem, some HEX bytes at the begin of the file to mark its file format. To solve it:

  1. Open C:/Program Files/Android/Android Studio/lib/jdkAnnotations.jar with winRar or other tool capable of editing .jar files.
  2. Find annotations.xml in /java/awt/event/ iside the .jar and open it with a text viewer.
  3. Copy its content to a new file with the same name (annotations.xml) anywhere in your computer.
  4. Delete the original annotations.xml file inside the .jar file, and add your copy to the same location.

Then in your Android project project try to click in the Attach annotations option, and that should solve the problem.

Good luck!

like image 36
novakz Avatar answered Nov 03 '22 00:11

novakz