运行测试时出现“错误:Gradle:prolog中不允许内容”(“Error:Gradle: Content is not allowed in prolog” when running tests)

编程入门 行业动态 更新时间:2024-10-22 13:30:06
运行测试时出现“错误:Gradle:prolog中不允许内容”(“Error:Gradle: Content is not allowed in prolog” when running tests)

使用Android Studio,当我尝试运行所有单元测试时,它几乎立即失败,并在Messages(Gradle Build)中出现以下错误:

Error:Gradle: Content is not allowed in prolog. Error:Gradle: Execution failed for task ':Module:mergeDebugAndroidTestResources'. > /Users/me/path/to/my/project/src/test/resources/fixtures/activity_feed.json:0:0: Error: Content is not allowed in prolog.

似乎内容的另一个变体不允许在prolog错误中,这通常没有意义,因为我发现了搜索解决方案。 在我的例子中,它指向一个JSON文件,显然不包含任何prolog代码。

Using Android Studio, when I try to run all my Unit Tests, it fails almost immediately with following error in Messages (Gradle Build):

Error:Gradle: Content is not allowed in prolog. Error:Gradle: Execution failed for task ':Module:mergeDebugAndroidTestResources'. > /Users/me/path/to/my/project/src/test/resources/fixtures/activity_feed.json:0:0: Error: Content is not allowed in prolog.

Seems like yet another variant of Content is not allowed in prolog error, which doesn't often makes sense, as I found out searching for a solution. In my case, it points to a JSON file, which obviously doesn't contain any prolog code.

最满意答案

查找构建变体视图:

左侧工具窗格 查看 - >工具窗口 - >构建变体

在那里,找到:

测试工件: Android Instrumentation测试

而是Android Instrumentation Tests选择:

测试工件: 单元测试

Find Build Variants view:

left tool pane View -> Tool Windows -> Build Variants

Once there, locate:

Test Artifact: Android Instrumentation Tests

and instead Android Instrumentation Tests select:

Test Artifact: Unit Tests

更多推荐

本文发布于:2023-07-16 12:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1128580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中不   错误   测试   内容   Gradle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!