Search code examples
androidandroid-manifestreceiver

Malformed android manifest violating terms


I just got an email from Google Play, notifying me that my app will be removed as "we have determined that your app has a malformed AndroidManifest.xml file which may make it difficult for users to uninstall the app"

The app is plain simple: sends the device to standby.

Here is their recommendation

In particular, the app’s AndroidManifest.xml contains a malformed Device Admin receiver entry (as identified by meta-data named android.app.device_admin). To be a well-formed Device Admin, the entry must declare an Intent filter for Intents with action android.app.action.DEVICE_ADMIN_ENABLED. The suggested modification is to make the entry well-formed if the receiver is a Device Admin, or remove the meta-data named android.app.device_admin if the receiver is not a Device Admin.

And here is the part from Android manifest

        <receiver
            android:name=".MyAdmin"
            android:permission="android.permission.BIND_DEVICE_ADMIN" >
            <meta-data
                android:name="android.app.device_admin"
                android:resource="@layout/policies" >
                <intent-filter>
                    <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" >
                    </action>
                </intent-filter>
            </meta-data>
        </receiver>

To be honest, I don't understand how to fix it. Any ideas ?


Solution

  • The problem is likely that you've nested <intent-filter>...</intent-filter> under the meta-data tag, whereas both should be direct children of <receiver />. According to the documentation, a valid declaration should look as follows:

    <receiver>
        <intent-filter> . . . </intent-filter>
        <meta-data />
    </receiver>
    

    http://developer.android.com/guide/topics/manifest/manifest-intro.html