Skip to content Skip to sidebar Skip to footer

Android Broadcast Receiver Error: Class Not Found Exception

I have a Broadcast receiver setup so that a pop-up message is displayed to the user after each upgrade of my app, or if this is the first time the package is installed. I tested th

Solution 1:

from the android documentation on "android:exported" attribute for a receiver:

Whether or not the broadcast receiver can receive messages from sources outside its application — "true" if it can, and "false" if not. If "false", the only messages the broadcast receiver can receive are those sent by components of the same application or applications with the same user ID. The default value depends on whether the broadcast receiver contains intent filters. The absence of any filters means that it can be invoked only by Intent objects that specify its exact class name. This implies that the receiver is intended only for application-internal use (since others would not normally know the class name). So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the broadcast receiver is intended to receive intents broadcast by the system or other applications, so the default value is "true"

Since your receiver has child intents the default value for android:exported is true. Just state this explicitly and it should function fine.

ie,

<receiverandroid:name=".FirstRunBroadcastReceiver"android:exported="true"><intent-filter><actionandroid:name="android.intent.action.PACKAGE_REPLACE"/><dataandroid:scheme="package"android:path="com.name.pkg.app_name"></intent-filter>

Solution 2:

Is package declaration in your FirstRunBroadcastReceiver class as follows?

package com.name.pkg.app_name;

According to your exception stack it should be so.

Solution 3:

I am a newbie with android development and my solution was a simple one caused my stupidity. I had renamed my broadcastreceiver file and when I tried to run the application I received the classdefnotfound error. I ended up cleaning and rebuilding the project and the error was removed.

Post a Comment for "Android Broadcast Receiver Error: Class Not Found Exception"