Android: Unable to instantiate activity / ClassNotFoundException

前端 未结 30 2743
粉色の甜心
粉色の甜心 2020-11-27 13:46

I recently published an app to the market and I\'m now getting an error by some user, the app presumably crashes right when it starts. Unfortunately I can\'t contact him dir

相关标签:
30条回答
  • 2020-11-27 14:19

    I was just having a problem with this myself, so I want to bring up what caused the problem for me. I had just included some new libraries setting up expansion APKs. The libraries are dependant on each other and I was only including one of them in my properties > android > libraries.

    So this could happen if the user is missing a library on their phone that most users have.

    It showed ClassNotFoundException on my main activity because it implements a class which was in the missing library.

    0 讨论(0)
  • 2020-11-27 14:21

    I don't see anything obviously wrong. All I can say is to try to test it in as many different configurations as possible.

    Test it in the emulator for every possible SDK level, follow the guidelines for testing on different sized screens (although that doesn't seem to be your problem).

    Try to test it on a phone from each of the major providers, if you can find friends that have them: HTC Sense, Motoblur, etc.

    If you only get one report, it might just be something screwy with that guys device. See if you get other, similar reports that add more data.

    0 讨论(0)
  • 2020-11-27 14:22

    Are you sure your package name is unique? I don't know what happen if the user has another app using the same package name, but maybe it can cause strange errors like this.

    EDIT: I just saw this page, it remembers me I already had this problem when downloading an app from the Android market. The app crashed on startup, I tried a lot of times but I always ended with the same result. Then I tried to uninstall the app, reinstall it, and everything worked fine. I'm still using it today and the problem never happened again.

    On my link, you can also see that they reproduced your error by making the app unreachable (unmount SD), so it's definitely not a problem with your code.

    0 讨论(0)
  • 2020-11-27 14:22

    I had the same issue in a recent Android project. The problem turned out to be pretty simple yet it was hard to locate. This happened to me then I refactored the package name of the entry point activity of the app. This created a conflict with the gen/.../R.java file, since the package there was not refactored. Eclipse did not complain, but at runtime i got the same error you posted: could not instantiate... classNotFoundException...

    Lesson learned from this: do NOT refactor the package name that holds your main activity!

    Hope this helps you or anyone breaking his/her head over this error!

    0 讨论(0)
  • 2020-11-27 14:23

    I was coming across this problem when I was including java Projects in my buildpath for my android project targeting JavaSE-1.7.

    For some reason my emulator would not throw a class not found if the java project it was including was originally created targeting JavaSE-1.6. Eclipse would give me a warning "Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment." But the Android emulator would launch and I would not get a classnotfoundexception

    So if you are including projects that target JavaSE-1.7, remake them targeting JavaSE-1.6 and this may solve your problem.

    Good luck!

    0 讨论(0)
  • 2020-11-27 14:25

    This problem might exist when you change the name of your class and update the manifest file and the manifest file is not updated on the emulator. Try uninstall the application from emulator and then reinstall it. This will work.

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