如何修复“在prolog中不允许”构建错误?

时间:2023-01-15 00:26:20

When I upgraded to Android Studio 0.6.1, I encountered a build issue with asset files. I kept getting "Content is not allowed in prolog" during the mergeDebugResources task. Since I couldn't find a suitable answer to this and have since found a solution, I've answered my own question to help other developers who face this issue.

当我升级到Android Studio 0.6.1时,我遇到了资产文件的构建问题。在mergeDebugResources任务期间,我一直在获取“prolog中不允许的内容”。由于我找不到合适的答案,并且找到了解决方案,我已经回答了我自己的问题,以帮助其他面临这个问题的开发人员。

2 个解决方案

#1


17  

It seems that the recent build changes since AS 0.6.1 and AS 0.8.1 no longer ignore custom asset directories. As a result, to get around the dreaded "Content is not allowed in prolog" you'll need to move your font files, properties and xml files to "src/main/assets" instead of your custom mapped assets directory. I hope this helps.

似乎最近的构建变更从0.6.1开始,而0.8.1不再忽略自定义资产目录。因此,要绕过令人恐惧的“prolog中不允许的内容”,您需要将字体文件、属性和xml文件移动到“src/main/assets”,而不是自定义映射的assets目录。我希望这可以帮助。

#2


1  

I resolved this issue in this way, first create directory "src/main/assets/fonts" and paste the file then mention this code in build.gradle

我以这种方式解决了这个问题,首先创建目录“src/main/assets/font”并粘贴文件,然后在build.gradle中提到这段代码

android { sourceSets { main { assets.srcDirs = ['src/main/assets/fonts/', 'src/main/assets/fonts/'] } } }

#1


17  

It seems that the recent build changes since AS 0.6.1 and AS 0.8.1 no longer ignore custom asset directories. As a result, to get around the dreaded "Content is not allowed in prolog" you'll need to move your font files, properties and xml files to "src/main/assets" instead of your custom mapped assets directory. I hope this helps.

似乎最近的构建变更从0.6.1开始,而0.8.1不再忽略自定义资产目录。因此,要绕过令人恐惧的“prolog中不允许的内容”,您需要将字体文件、属性和xml文件移动到“src/main/assets”,而不是自定义映射的assets目录。我希望这可以帮助。

#2


1  

I resolved this issue in this way, first create directory "src/main/assets/fonts" and paste the file then mention this code in build.gradle

我以这种方式解决了这个问题,首先创建目录“src/main/assets/font”并粘贴文件,然后在build.gradle中提到这段代码

android { sourceSets { main { assets.srcDirs = ['src/main/assets/fonts/', 'src/main/assets/fonts/'] } } }