loadedapk.java_java.lang.RuntimeException: Unable to instantiate application android.app.Application...

可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):

问题:

This question already has an answer here:

So I get this error from time to time. It's at the application launching from the Run button in Eclipse. this occurs once every 4-5 times. Anyone has an idea what's going on.

I really appreciate it! 05-01 18:08:31.109: W/dalvikvm(15491): threadid=1: thread exiting with uncaught exception (group=0x40a311f8) 05-01 18:08:31.109: E/AndroidRuntime(15491): FATAL EXCEPTION: main 05-01 18:08:31.109: E/AndroidRuntime(15491): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.LoadedApk.makeApplication(LoadedApk.java:482) 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938) 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.ActivityThread.access$1300(ActivityThread.java:123) 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185) 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.os.Handler.dispatchMessage(Handler.java:99) 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.os.Looper.loop(Looper.java:137) 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.ActivityThread.main(ActivityThread.java:4424) 05-01 18:08:31.109: E/AndroidRuntime(15491): at java.lang.reflect.Method.invokeNative(Native Method) 05-01 18:08:31.109: E/AndroidRuntime(15491): at java.lang.reflect.Method.invoke(Method.java:511) 05-01 18:08:31.109: E/AndroidRuntime(15491): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 05-01 18:08:31.109: E/AndroidRuntime(15491): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 05-01 18:08:31.109: E/AndroidRuntime(15491): at dalvik.system.NativeStart.main(Native Method) 05-01 18:08:31.109: E/AndroidRuntime(15491): Caused by: java.lang.NullPointerException 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362) 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305) 05-01 18:08:31.109: E/AndroidRuntime(15491): at android.app.LoadedApk.makeApplication(LoadedApk.java:474) 05-01 18:08:31.109: E/AndroidRuntime(15491): ... 11 more

回答1:

Looked into the ICS source code - It seems like for whatever reason the Package Manager can't get your package info - it could just be an eclipse/ADT bug where eclipse holds some kind of lock on the file, but whatever it is, it doesn't seem like something that you could cause with your code. I would suggest running a clean, uninstalling the app from the emulator/device, or if those don't work, you might try a fresh eclipse workspace.

Another thing that might be an issue is if you're using a Library project - try unlinking the two, cleaning, and then linking them back up again - but thats it for my bag o' tricks :)

UPDATE: yorkw gives a better explanation for why this occurs and its resolution here: RuntimeException: Unable to instantiate application

回答2:

This is (unsurprisingly*) a bug in Eclipse/ADT/adb. I managed to fix it by uninstalling my app from the emulator. Hopefully it won't come back, but I'm not going to hold my breath.

*Seriously, Eclipse & ADT seem to be the buggiest pieces of software I've ever used. In only one day I've run into at least four different very annoying bugs! (This one, ddms broken pipe, workspace in use but it isn't, dex out of memory.) It's embarrassingly shoddy. Thank god we have stackoverflow!

Edit: I spoke too soon. The bug returns as soon as you run the app a second time.

回答3:

I struggled with this error too.The error occurs inconsistently. Found out it was a library dependency that was not included in the build path for API level 16 (android-support-v4)

回答4:

I also get this error when running my app on 4.x or above both emulator and actual device, but the error does not prevent my app to be launched, so I simply ignore it.

回答5:

It also happens if you're trying to call new Intent(getActivity(), ActivityXY.class) when activity was finished and garabage collected. It's usually an indicator that you forgot to cancel some asynchronous operations when the activity/fragment was destroyed

回答6:

This is an error from the .project file in your project. You can open other .project files on a project without errors for comparison. Almost, you can see wrong with tag in this file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值