問題描述
當我運行我的應用程序時,每次我的 logcat 中都會出現以下異常:
When I run my application, everytime I am getting the below exception in my logcat:
04-14 09:29:53.965: W/dalvikvm(1020): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
04-14 09:29:53.985: E/AndroidRuntime(1020): FATAL EXCEPTION: main
04-14 09:29:53.985: E/AndroidRuntime(1020): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.os.Handler.dispatchMessage(Handler.java:99)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.os.Looper.loop(Looper.java:137)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-14 09:29:53.985: E/AndroidRuntime(1020): at java.lang.reflect.Method.invokeNative(Native Method)
04-14 09:29:53.985: E/AndroidRuntime(1020): at java.lang.reflect.Method.invoke(Method.java:511)
04-14 09:29:53.985: E/AndroidRuntime(1020): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-14 09:29:53.985: E/AndroidRuntime(1020): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-14 09:29:53.985: E/AndroidRuntime(1020): at dalvik.system.NativeStart.main(Native Method)
04-14 09:29:53.985: E/AndroidRuntime(1020): Caused by: java.lang.NullPointerException
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
04-14 09:29:53.985: E/AndroidRuntime(1020): at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
04-14 09:29:53.985: E/AndroidRuntime(1020): ... 11 more
注意:當我從模擬器中卸載應用程序并運行它時,我沒有收到此異常,但是當我在模擬器中重新運行已安裝的應用程序時,我得到了這個.請幫忙.
Note: When I uninstall the app from the emulator and run it, then I don't get this exception but when I re-run the installed application in emulator, I am getting this. Please help.
推薦答案
這是當 dalvik 重新安裝 .apk 文件并嘗試重用或回收之前打開的活動/視圖時,底層框架引發的詳細錯誤消息包(如果您還沒有關閉之前安裝的應用程序).它與您的應用無關,此外,您的應用不太可能因最終用戶設備上出現此詳細錯誤消息而凍結或崩潰.
This is a verbose error message raised by underlying framework when dalvik re-install .apk file and trying to reuse or recycle the previous opened activity/view from the same package (if you haven't closed the previous installed app yet). It has nothing to do with your app, moreover, it is very unlikely that your app will get freezed or crashed cause by this verbose error message on end user's device.
似乎這個 dalvik 詳細錯誤日志只發生在 Android 4.0 系統上,我自己在 Android 3.2 和 2.3.3 運行環境中對其進行了測試,您無法在其中復制以在它們都不顯示此消息.here 之前已經討論過類似的問題,并且有人已經在 Android 問題跟蹤器.
It seems that this dalvik verbose error log only happend on Android 4.0 system, I've tested it myself on Android 3.2 and 2.3.3 running environment, where you cannot replicate to get this message shown on neither of them. A similar question has been discussed before at here and someone has filled a bug report in Android Issues Tracker.
我認為你暫時不用太在意這個冗長的錯誤日志,如果你在Logcat中查看更多這個紅色錯誤之前和之后的日志,你可以看到完整的故事,發現之前打開的活動/視圖(標記為死亡狀態)被殺死,新安裝的視圖最終被彈出.
I don't think you should concern too much about this verbose error log at the moment, if you look more logs before and after this red error in Logcat, you can see the full story and find that the previous opened activity/view (which are marked as died state) get killed and the newly re-installed one get poped ultimately.
這篇關于RuntimeException:無法實例化應用程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!