Android app ClassNotFoundException for main activity

后端 未结 12 675
灰色年华
灰色年华 2020-12-06 10:07

Most of the devices can run my app but I got this error report :

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.company.app/com         


        
12条回答
  •  长情又很酷
    2020-12-06 10:37

    I just ran into this problem. Turns out it was because I had moved my MainActivity into a new package.

    What I did was move it from

    com.example.MainActivity
    

    into

    Activity
    

    so in my manifest it looked like this:

     android:name="Activity.MainActivity"`
    

    Solved it by moving it back into the original package. It can also be solved by renaming your packages correctly:

    Eg: com.example.Activity.MainActivity

    Hope this helps someone.

提交回复
热议问题