Android Studio构建错误:“序言中不允许包含内容。”

时间:2020-01-11 16:40:56

标签: java android android-studio gradle build

我创建了一个全新的项目,未对任何代码进行编辑,当我运行代码时,出现此错误。该错误在“ Execute taskAction $ gradle” 中,并且由“ org.xml.sax.SAXParseException;” 引起。

org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.rethrowFailure(DefaultConfiguration.java:1195)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$2100(DefaultConfiguration.java:138)
    at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:1170)
    at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:72)
    at org.gradle.api.internal.file.CompositeFileCollection.iterator(CompositeFileCollection.java:64)
    at org.gradle.api.internal.file.AbstractFileCollection.getSingleFile(AbstractFileCollection.java:59)
    at com.android.build.gradle.internal.res.namespaced.Aapt2DaemonManagerService.registerAaptService(Aapt2DaemonManagerService.kt:83)
    at com.android.build.gradle.internal.res.namespaced.Aapt2DaemonManagerService.registerAaptService$default(Aapt2DaemonManagerService.kt:81)
    at com.android.build.gradle.internal.res.namespaced.Aapt2DaemonManagerService.registerAaptService(Aapt2DaemonManagerService.kt)
    at com.android.build.gradle.tasks.MergeResources.getResourceProcessor(MergeResources.java:172)
    at com.android.build.gradle.tasks.MergeResources.doFullTaskAction(MergeResources.java:224)
    at com.android.build.gradle.internal.tasks.IncrementalTask.handleIncrementalInputs(IncrementalTask.kt:107)
...

上面是错误消息的开始,下面是错误消息的结束。

Caused by: org.xml.sax.SAXParseException; systemId: file:/C:/Users/USERNAME/.gradle/caches/modules-2/files-2.1/com.android.tools.build/aapt2/3.5.3-5435860/8486d2ab77c5f5659feca22c0c2da01d74f65541/aapt2-3.5.3-5435860.pom; lineNumber: 2; columnNumber: 1; Content is not allowed in prolog.
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:150)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.PomReader.parseToDom(PomReader.java:256)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.PomReader.access$100(PomReader.java:60)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.PomReader$2.transform(PomReader.java:142)
    ... 170 more

请记住,我从未编辑过代码。几个月前,我有一个正在运行的应用程序,但不确定当时所做的更改,但是当我开始使用新应用程序时,这是我收到的错误。我已卸载并重新安装,并删除了.android文件夹,仍然出现此错误。

Gradle插件版本:3.5.3, 版本版本:5.4.1, Android Studio版本:3.5.3,

1 个答案:

答案 0 :(得分:1)

尝试一下,

1)。关闭android studio。

2)。删除以下目录的所有内容。

                 C:\Users\USER_NAME\.android\build-cache
                 C:\Users\USER_NAME\.android\cache
                 C:\Users\USER_NAME\.gradle\caches

3)。启动Android Studio。