Thursday, 3 February 2022

XML not found in android module

I am trying to break down parts of my android application in separate modules. My app uses Device Administrator API and I am trying to separate this part in to a standalone module.

I moved everything related to this in to another module(named admin module). But on building the project I am getting the following error

ERROR:...\app\build\intermediates\packaged_manifests\debug\AndroidManifest.xml:376: AAPT: error: resource xml/device_admin_policies (aka com.app.package:xml/device_admin_policies) not found.

It's trying to look for the xml file in app module instead of the admin module. If I move back this file to app module it works but if the file is in admin module then I get this error.

I am experimenting something with Device Admin API and for that I need xml file to be in admin module. I am not sure if its possible to point it somehow to get the file from admin module.

Admin Module Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:dist="http://schemas.android.com/apk/distribution"
    package="com.app.package.ad">

    <dist:module
        dist:instant="false"
        dist:title="@string/title_lock">
        <dist:delivery>
            <dist:install-time />
        </dist:delivery>

        <dist:fusing dist:include="false" />
    </dist:module>

    <application android:hasCode="true">
        <activity
            android:name=".MainActivity"
            android:exported="false" />

        <activity android:name=".AdminPermissionActivity" />

        <receiver
            android:name=".admin.DeviceAdministrator"
            android:permission="android.permission.BIND_DEVICE_ADMIN"
            android:exported="false">
            <meta-data
                android:name="android.app.device_admin"
                android:resource="@xml/device_admin_policies" />

            <intent-filter>
                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
                <action android:name="android.app.action.DEVICE_ADMIN_DISABLED" />
                <action android:name="android.app.action.ACTION_PASSWORD_FAILED" />
                <action android:name="android.app.action.ACTION_PASSWORD_SUCCEED" />
                <action android:name="android.intent.action.USER_PRESENT" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

xml file (device_admin_policies.xml)

Do note the error I am getting is for the build file when manifest are merged together at compile time.



from XML not found in android module

No comments:

Post a Comment