prolog 中不允许从 Eclipse 迁移到 Android Studio 错误内容

Posted

技术标签:

【中文标题】prolog 中不允许从 Eclipse 迁移到 Android Studio 错误内容【英文标题】:Migrating from Eclipse to Android Studio Error Content is not allowed in prolog 【发布时间】:2014-12-27 02:50:56 【问题描述】:

我看到很多人提到这个问题,但大多数人说它是间歇性发生的。对我来说,我根本无法编译或运行我的应用程序。存在构建错误,并且始终存在。 我还看到堆栈交换问题,说明这是由于 Gradle 版本,它只需要在 build.gradle 文件中更新。我已经在使用比大多数问题要新得多的版本。 这似乎是由我的资源文件(包括我的所有可绘制对象和字符串)引起的错误。

注意这个项目在 Eclipse 中运行良好,我让它在硬件上运行。当我将它导入 Studio 时出现错误。

我尝试了以下方法。 -重新启动工作室 -清理项目然后重建 - 将资源文件移动到项目内文件系统中的其他任何地方

Information:Gradle tasks [:app:compileDebugSources]
:app:preBuild
:app:preDebugBuild
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
Error:Content is not allowed in prolog.
:app:mergeDebugResources FAILED
C:\Users\jezell\Documents\androidStudioProjects\DefenderHud\app\src\main\res\drawable_hdpi\app_setup.png
Error:Error: Content is not allowed in prolog.
Error:Execution failed for task ':app:mergeDebugResources'.
> C:\Users\jezell\Documents\AndroidStudioProjects\DefenderHud\app\src\main\res\drawable_hdpi\app_setup.png:0:0: Error: Content is not allowed in prolog.
Information:BUILD FAILED
Information:Total time: 2 mins 37.404 secs
Information:3 errors
Information:0 warnings
Information:See complete output in console

【问题讨论】:

您是否尝试将drawable_hdpi 目录重命名为drawable-hdpi 等? 我的可绘制目录最初是用短划线字符命名的,当它们来自 eclipse 时,它​​给了我一个错误,说短划线是非法字符,这就是为什么我将所有内容都切换为下划线。 使用破折号应该没有任何问题。您可以尝试手动重命名 Android Studio 之外的目录,例如,使用文件浏览器。您能否确认app_setup.png 文件完好无损? 当我第一次导入项目时出现以下错误,所以我切换到下划线:错误:任务':app:mergeDebugResources'的执行失败。 > C:\Users\jezell\Documents\AndroidStudioProjects\app\src\main\res\drawable-hdpi\vert_line_test.PNG:错误:文件名无效:必须仅包含小写字母和数字([a-z0-9_.] ) 根据此错误消息,您可能应该将文件名从v‌​ert_line_test.PNG 更改为v‌​ert_line_test.png 等。您是否尝试将目录重命名为使用破折号?能否确认 app_setup.png 文件完好无损? 【参考方案1】:

此问题的解决方案是重命名所有错误命名的文件,详细情况下将大写字母改为小写(例如,​vert_line_test.PNGvert_line_test.png)等。

【讨论】:

以上是关于prolog 中不允许从 Eclipse 迁移到 Android Studio 错误内容的主要内容,如果未能解决你的问题,请参考以下文章

第 1 行错误:prolog 中不允许有内容

android错误:prolog中不允许内容

org.xml.sax.SAXParseException:prolog 中不允许内容

Prolog SAXParserException 中不允许内容

gradle build error [致命错误] checker-qual-2.5.2.pom:2:1:prolog 中不允许内容

Hadoop mapred-site.xml 1:1:prolog 中不允许内容