gpt4 book ai didi

android - 是否可以模拟发布构建类型的位置

转载 作者:行者123 更新时间:2023-11-29 14:24:30 25 4
gpt4 key购买 nike

我想在 Android 应用的发布构建类型中模拟位置。我在 app/src/mockable/AndroidManifest.xml

中创建了一个特殊风格的 "mockable" list
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
</manifest>

但 Android lint 似乎阻止在发布构建类型中使用此权限。对于命令:

 ./gradlew assembleRelease

我得到了输出:

:app:lintVitalMockableRelease                 
/home/fr/app/src/mockable/AndroidManifest.xml:3: Error: Mock locations should only be requested in a debug-specific manifest file (typically src/debug/AndroidManifest.xml) [MockLocation]
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Explanation for issues of type "MockLocation":
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
<uses-permission> element there. A typical path to a debug manifest
override file in a Gradle project is src/debug/AndroidManifest.xml.

1 errors, 0 warnings

是否可以生成具有位置模拟权限的发布应用?

最佳答案

针对该特定权限禁用 MockLocation lint 检查,即

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION"
tools:ignore="MockLocation" />
</manifest>

(引用http://tools.android.com/tips/lint-checks)

关于android - 是否可以模拟发布构建类型的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26801252/

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