I just s开发者_如何学Gotarted 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. The exception happens in: ActivityThread.performLaunchActivity
It runs fine on 1.6 and later, so I assume I'm using something that isn't supported on 1.5. But how can I find out what it is? Any tips on how to debug this would be greatly appreciated.
Thanks.
If you have imported jars, verify that they are in the /libs directory and not in the /lib directory and they are imported as jars and not as external jars
I had the same problem today. It's difficult to identify which class is not supported. The stack trace doesn't really shed any light on it, it just gives the somewhat misleading message that your activity class cannot be found. A couple API's that I have used that I know are not in Android 1.5 are: - Bluetooth (2.0 and up) - Text to Speech (1.6 and up)
I ran into this issue because I added support for text to speech to my app and didn't think to check the docs first to make sure text to speech is supported on Android 1.5. I was dismayed to learn it was only added in Android 1.6. To work around the problem I had to do a couple things:
- Remove the "import android.speech.tts.*" from my activity
- Create wrapper classes that mirror the text to speech API and call the real text to speech classes from there.
- Put if statements around the calls to my wrapper class to make sure I only call out to it if the Android SDK level is 1.6 or above. You can check the Android SDK level by inspecting android.os.Build.VERSION.SDK
- In your Android Market listing, indicate that the text to speech functionality is only available if you have Android 1.6 or higher installed.
The nice thing about this approach is that in the future, when I decide to abandon support for Android 1.5 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.
精彩评论