Force close before onCreate, activity class not found exception
I just started testing my app on Android 1.5 and it doesn't want to run at all. I have a breakpoint in onCreate on my main activity, but I get a ClassNotFound exception even before reaching that. The class not found appears to be the class of my main activity. Exception happens at: ActivityThread.performLaunchActivity
It works fine on 1.6 and later, so I guess I am using something that is not supported on 1.5. But how can I know what it is? Any advice on how to debug this would be greatly appreciated.
Thanks.
a source to share
I had the same problem today. It is difficult to determine which class is not supported. The stack trace doesn't really shed light on it, it just gives a somewhat misleading message that your activity class could not be found. A couple of APIs I have used that I know not in Android 1.5: - Bluetooth (2.0 and above) - Text to Speech (1.6 and above)
I ran into this issue because I added text-to-speech support to my app and didn't think to validate documents first to ensure text-to-speech support on Android 1.5. I was horrified to learn that it was only added in Android 1.6. To get around this problem, I had to do a couple of things:
- Remove "import android.speech.tts. *" From my activity.
- Create wrapper classes that mirror the text-to-speech API and call the real text classes from there.
- Put if statements around the calls to my wrapper class to make sure I only refer to it if the Android SDK level is 1.6 or higher. You can check the Android SDK level by checking the android.os.Build.VERSION.SDK file
- In the Android Market listing, indicate that text functions are only available if Android 1.6 or later is installed.
The best part about this approach is that in the future, when I decide to drop Android 1.5 support, I can easily change my calls to my wrapper class to just call the text-to-speech API directly and rip out the wrapper classes.
I did something similar for my bluetooth code.
a source to share