I followed the directions verbatim in this Android tutorial, copying/pasting the code from the site to my app.
http://de开发者_运维技巧veloper.android.com/resources/tutorials/views/hello-tabwidget.html
However, when I try to run in the Android emulator, I get the error:
"The application Hello Tab Widget has stopped unexpectedly. Please try again."
I tried debugging by introducing a breakpoint in the first line of the onCreate method, but the error occurs before the breakpoint is even hit. Any idea of what is going wrong, or any other way I can debug this issue? I am using Eclipse.
As your symptoms are very generic, you should try to see all the logs that are generated by your application. You can do so by typing:
adb logcat
There, you can identify the exact point where your application is crashing. Ususally you will see that a Exception is thrown which can give you an idea of what's going on. You can edit your post and put revelant information of the log, as well as some code you have written so that we can help you easly.
you likely were messing around with class names and your AndroidManifest.xml no longer indicates the main activity.
make sure:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
is inside the <activity>
tags in AndroidManifest.xml file.
You can also configure this via the manifest GUI in eclipse if you want.
This might be because of the activity name mismatch in the manifest.
So check whether the activity name what you have specified in your code and the in the manifest are both same.
精彩评论