Android应用程序意外停止

时间:2012-09-02 07:22:52

标签: android android-wifi

我写了一个连接互联网的android程序。

我收到以下错误:

The application has stopped unexpectedly.Please try again..

有什么问题?

Eclipse中的Log cat如下:

09-02 12:43:42.421: W/dalvikvm(12362): threadid=1: thread exiting with uncaught exception (group=0x40018578)
09-02 12:43:42.437: E/AndroidRuntime(12362): FATAL EXCEPTION: main
09-02 12:43:42.437: E/AndroidRuntime(12362): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.android.networkusage/com.example.networkusage.NetworkActivity}: java.lang.ClassNotFoundException: com.example.networkusage.NetworkActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.android.networkusage-1.apk]
09-02 12:43:42.437: E/AndroidRuntime(12362):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at android.os.Looper.loop(Looper.java:130)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at android.app.ActivityThread.main(ActivityThread.java:3687)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at java.lang.reflect.Method.invokeNative(Native Method)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at java.lang.reflect.Method.invoke(Method.java:507)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at dalvik.system.NativeStart.main(Native Method)
09-02 12:43:42.437: E/AndroidRuntime(12362): Caused by: java.lang.ClassNotFoundException: com.example.networkusage.NetworkActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.android.networkusage-1.apk]
09-02 12:43:42.437: E/AndroidRuntime(12362):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
09-02 12:43:42.437: E/AndroidRuntime(12362):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1565)
09-02 12:43:42.437: E/AndroidRuntime(12362):    ... 11 more

2 个答案:

答案 0 :(得分:1)

发现我的包名是:

com.example.android.networkusage

并且清单上显示为:

机器人:名称= “com.example.networkusage.NetworkActivity”

所以将清单改为:

机器人:名称= “com.example.android.networkusage.NetworkActivity”

答案 1 :(得分:0)

您的com.example.networkusage.NetworkActivity课程似乎缺失了。

如果在外部库中声明,请将 jar文件添加到“ libs ”文件夹,然后将其添加到构建路径然后再次构建您的项目

不要忘记清理它!