Проблема: реализация ограничений приложений и ошибок Lint в app_restrictions.xml

Я работаю над Android MDM и имею файл app_restrictions.xml в папке /src/main/res/xml/. Используемый мной MDM не показывает мне значение ограничения, даже значение по умолчанию. Все шаги, указанные в этой ссылке, были выполнены для установки ограничений приложения: https://developer.android.com/training/enterprise/app-restrictions.html, но я получаю пакет [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="[email protected]" />
<restriction/>
</restrictions>

Кроме того, ворс показывает мне ниже ошибки, хотя я смог подавить его в градации с помощью параметров ворса, но просто интересно, не является ли это причиной проблемы, с которой я столкнулся. Пожалуйста, дайте мне знать, почему я получаю эти ошибки.

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

person Surbhi    schedule 03.02.2016    source источник
comment
Вы успешно внедрили MDM в свое приложение. Не могли бы вы проверить это? Не могли бы вы помочь мне в следующем. Помощь очень ценится stackoverflow.com/questions/42112688/   -  person Manu    schedule 16.02.2017


Ответы (1)


RE: Ошибки lint У вас есть пустой элемент restriction в строке 8 <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="[email protected]" />
<restriction/> <!-- Error here -->
</restrictions>
person Nagesh Susarla    schedule 06.02.2016
comment
Спасибо, Нагеш, это устранило ошибки lint, но вы знаете, почему я получаю пустую посылку в Bundle appRestrictions = myRestrictionsMgr.getApplicationRestrictions();, даже если я загрузил свое приложение через MDM. - person Surbhi; 08.02.2016
comment
Это исключение? Также вы можете попробовать пример приложения, указанный на developer.android.com/samples/AppRestrictionSchema/ - person Nagesh Susarla; 08.02.2016