这两天和同学在搞一个程序,这之间合并出了太多问题啊。先是在emulator上报the application
has stopped unexpectedly,然后又在真机在报the application has stopped unexpectedly。差点奔溃,还好克服了。
在emulator报错的原因是,
adb logcat下面能够大致定位
错误的原因,之后步步调试就行了。
emulator上能够运行,一般真机也就没问题,不过遇到不同
版本的差异就可怜了。首先真机运行不了,没有报错信息。直到意识到版本问题(emulator是2.1的,真机是2.3的),创建个emulator2.3,果然报错了。
错误提示:
java.lang.RuntimeException: Unable to instantiate application cz.teamnovak.droid.Novak ESC Track guide: java.lang.ClassNotFoundException: cz.teamnovak.droid.Novak ESC Track guide in loader dalvik.system.PathClassLoader[/data/app/cz.teamnovak.droid-1.apk]
at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:649)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4232)
at android.app.ActivityThread.access$3000(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: cz.teamnovak.droid.Novak ESC Track guide in loader dalvik.system.PathClassLoader[/data/app/cz.teamnovak.droid-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at android.app.Instrumentation.newApplication(Instrumentation.java:942)
at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:644)
... 11 more
果断google,良久觅得解药。
将AndroidManifest.xml中application下android:name去掉即可
参考链接:
http://yelinqing.iteye.com/blog/765384
http://stackoverflow.com/questions/3781151/java-lang-classnotfoundexception-on-working-app