Mar*_*och 1 android android-manifest android-location android-lint
我想在发布版本类型的Android应用中模拟位置.我创造了一种特殊的味道"可模仿"的清单app/src/mockable/AndroidManifest.xml
<?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>
Run Code Online (Sandbox Code Playgroud)
但似乎Android lint阻止在发布版本类型中使用此权限.对于命令:
./gradlew assembleRelease
Run Code Online (Sandbox Code Playgroud)
我有输出:
: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
Run Code Online (Sandbox Code Playgroud)
是否可以使用位置模拟权限生成发布应用程序?
小智 6
禁用该特定权限的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>
Run Code Online (Sandbox Code Playgroud)
(请参阅http://tools.android.com/tips/lint-checks)
| 归档时间: |
|
| 查看次数: |
3741 次 |
| 最近记录: |