Unable to instantiate receiver java.lang.ClassNotFoundException

前端 未结 4 756
醉酒成梦
醉酒成梦 2020-12-17 23:17

I got an error in my android application when it tries to instantiate a receiver that i use to start a service on boot up. The error is obvious, it can not find the class fi

相关标签:
4条回答
  • 2020-12-17 23:35

    You have to put your Receiver in some package. The system won't be able to instantiate it 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. I tried it just now and worked. :)

    0 讨论(0)
  • 2020-12-17 23:43

    try:

    <receiver android:name=".BootReceiver" >
    

    It adds the package name itself because you defined:

    package="dti.obd.reader"
    
    0 讨论(0)
  • 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

    0 讨论(0)
  • 2020-12-17 23:56

    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/

    0 讨论(0)
提交回复
热议问题