• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

"Content is not allowed in prolog error" despite valid XML

Mimsy

Lurker
Jun 23, 2023
4
1
I recently changed my project to a Compose app. I safely deleted my now redundant fragments and their XML files, and removed all references to them.

Now when I try and build my file, it crashes with the error:

Code:
Execution failed for task ':app:extractDeepLinksDebug'.
> org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

The only XML file I changed that still exists is my main acitivity XML, and it is correct. I opened it in a basic text editor and there are no invisible characters. I manually deleted the caches from the .android and .gradle folders, and deleted my build folder. I'm still getting this error. What are other possible reasons for it? Here is my XML file:

Code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="?android:attr/actionBarSize"
    android:id="@+id/content">
    <androidx.compose.ui.platform.ComposeView
        android:id="@+id/main_compose"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

And here are the first of hundreds of lines of stack trace:

Code:
    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)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at com.android.utils.PositionXmlParser.parseInternal(PositionXmlParser.java:287)
    at com.android.utils.PositionXmlParser.parseInternal(PositionXmlParser.java:236)
    at com.android.utils.PositionXmlParser.parse(PositionXmlParser.java:182)
    at com.android.utils.PositionXmlParser.parse(PositionXmlParser.java:98)
    at com.android.utils.PositionXmlParser.parse(PositionXmlParser.java:136)
    at com.android.manifmerger.NavigationXmlLoader.load(NavigationXmlLoader.kt:48)
    at com.android.build.gradle.tasks.ExtractDeepLinksTask.doTaskAction(ExtractDeepLinksTask.kt:92)
    at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(BaseTask.kt:66)
    at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)
    at com.android.build.gradle.internal.tasks.NonIncrementalTask.taskAction

I can only assume that perhaps some kind of reference remains to my deleted XML files, but I can't find any. Are there hidden files, and if so, how do I access them?
 
Did you solve?
Yes, yesterday. It turns out that Android hates having empty directories, and since I had deleted all the navigation components that use Fragments and XML and switched to Compose navigation, I had an empty "menu" directory and an empty "navigation" directory. I hadn't deleted them in case I wanted to backtrack! But as soon as I deleted the empty directories, the error went. It was nothing to do with a prolog in my XML at all. Total red herring of an error message.
 
  • Like
Reactions: olbriar
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones