In my manifest file, I declare two BroadcastReceiver
for my Activity
. So far, while I was working in debug mode, the receivers were declared in the activity block and everything was fine. As my project is close to the end, I have decided to build an signed APK. The problem I face is that android studio returns me the following error :
Error:(20) Error: The <receiver> element must be a direct child of the <application> element [WrongManifestParent]
If I move the receivers blocks out of the activity block, the signed APK is generated. The consequence is that I get a runtime error when the receiver is called (java.lang.RuntimeException: Unable to instantiate receiver...).
How can I do to have my app run correctly both in debug and release mode?