0

我正在使用 Android MDM 并在 /src/main/res/xml/ 文件夹下拥有 app_restrictions.xml 文件。我使用的 MDM 没有显示限制的值,甚至没有显示默认值。已遵循此链接中提到的所有步骤来设置应用程序限制:https ://developer.android.com/training/enterprise/app-restrictions.html 但我得到了 Bundle[EMPTY_PARCEL]。下面是代码

app_restrictions.xml

<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
<restriction
android:key="MDMEmailKey"
android:title="Email"
android:restrictionType="string"
android:description="@string/email_address_mdm_description"
android:defaultValue="testtesttest@gmail.com" />
<restriction/>
</restrictions>

此外,虽然我能够通过 lint 选项在 gradle 中抑制它,但 lint 向我显示了以下错误,但只是想知道这是否不是我面临的问题的原因。请让我知道为什么我会收到这些错误。

Executing task ':project_name:lintVitalRelease' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
.../src/main/res/xml/app_restrictions.xml:8: Error: Missing required attribute android:key [ValidRestrictions]
    <restriction/>
    ~~~~~~~~~~~~~~
.../src/main/res/xml/app_restrictions.xml:8: Error: Missing required attribute android:restrictionType [ValidRestrictions]
    <restriction/>
    ~~~~~~~~~~~~~~
.../src/main/res/xml/app_restrictions.xml:8: Error: Missing required attribute android:title [ValidRestrictions]
    <restriction/>
    ~~~~~~~~~~~~~~

   Explanation for issues of type "ValidRestrictions":
   Ensures that an applications restrictions XML file is properly formed

   https://developer.android.com/reference/android/content/RestrictionsManager.html

3 errors, 0 warnings
4

1 回答 1

0

RE:lint 错误您在第 8 行有一个空restriction元素<restriction/> 只需将其删除,lint 错误就会消失。

<?xml version="1.0" encoding="utf-8"?>
<restrictions xmlns:android="http://schemas.android.com/apk/res/android">
<restriction
android:key="MDMEmailKey"
android:title="Email"
android:restrictionType="string"
android:description="@string/email_address_mdm_description"
android:defaultValue="testtesttest@gmail.com" />
<restriction/> <!-- Error here -->
</restrictions>
于 2016-02-06T00:46:52.993 回答