I recently refactored my package structure for an Android project and moved a BroadcastReceiver class to a different package. However, I forgot to update the receiver tag’s android:name field in the AndroidManifest.xml.
This BroadcastReceiver was used to send notifications to the client and this serious error simply meant that no notifications were sent. Unfortunately there is no compile time validation of this file or, it seems, any runtime error thrown to indicate a misconfiguration here.
Is there anything I can do from my side to validate these types of configurations? Perhaps this information can be accessed in a unit test and verified? Or, perhaps there is more verbose output I can configure to make sure error like this don’t go unnoticed in the future?
A warning might have shown up in LogCat, but probably not, as having zero receivers for a broadcast is a perfectly normal condition.
You can file a feature request to have Lint validate this portion of the manifest. Or, you can write your own script to analyze your source tree and manifest and include this as part of a customized Ant build script.
You can use
PackageManagerandqueryBroadcastReceivers()to confirm that theIntentyou use for broadcasts will resolve to 1+ receivers.