Unable to instantiate receiver java.lang.ClassNotFoundException

早过忘川 提交于 2019-11-29 06:40:57

You have to put your Reciever in some package. The system won't be able to instantiate if it is on the main package.

I had the same problem. Fortunately before searching the error on internet I was doing another java project. I just realized that the bug in there was similar to this one. Tried it just now and worked. :)

try:

<receiver android:name=".BootReceiver" >

It adds the package name itself because you defined:

package="dti.obd.reader"

I have also faced with this problem. Adding full package name to receiver definition in manifest file didn't help. Problem was there was an old odex file corresponding to my apk file. Android system loads classes from odex file so can not find receiver class.

Workarounds:

  • Remove the old odex file, or
  • Give a new name to your apk

http://www.addictivetips.com/mobile/what-is-odex-and-deodex-in-android-complete-guide/

You have to put your Reciever in some package Instead Add the full path of the Reciever

 <receiver android:name="com.yourpackage.BootReceiver" >

It Sounds Weired but in my case it resolved the Issue

Hope Someone will be fruitful with this experience

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!