gpt4 book ai didi

java - 使用模拟位置的 Android 错误测试应用程序

转载 作者:搜寻专家 更新时间:2023-11-01 08:46:45 25 4
gpt4 key购买 nike

我正在尝试测试基于 Android 位置的应用程序。

如果我可以在单元测试中模拟来自提供商的位置数据,那将非常有用。但是我不能将 ACCESS_MOCK_LOCATION 权限添加到 androidManifest.xml 因为当我这样做时它会给我一个错误:

Mock locations should only be requested in a debug-specific manifest file (typically src/debug/AndroidManifest.xml) Using a mock location provider (by requiring the permission android.permission.ACCESS_MOCK_LOCATION) should only be done in debug builds. In Gradle projects, that means you should only request this permission in a debug source set specific manifest file. To fix this, create a new manifest file in the debug folder and move the element there. A typical path to a debug manifest override file in a Gradle project is src/debug/AndroidManifest.xml.

但是当我将 AndroidManifest.xml 添加到 src/androidTest 目录时 - 它只是在测试时忽略它。

我做错了什么?

最佳答案

我刚遇到这个问题,我想我找到了解决方案。确保在您的设备开发人员选项中选中“访问模拟位置”(除了制作一个“src/debug/AndroidManifest.xml”文件声明使用 ACCESS_MOCK_LOCATION 权限,就像您已经在做的那样)。

关于java - 使用模拟位置的 Android 错误测试应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27502712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com