24

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
OWADVL
  • 10,704
  • 7
  • 55
  • 67
  • yeah code, and I am not sure what "once every 4-5 times" means, do you mean one out of five times ... ? – Idistic May 01 '12 at 15:26
  • 4
    The NPE is inside android code... how would she know what code to post? what SDK/ADT are you using? – JRaymond May 01 '12 at 15:27
  • Do you get it as the previously installed application is being uninstalled and the new one is installed? – dmon May 01 '12 at 15:34
  • 2
    See if my answer [here](http://stackoverflow.com/questions/10150899/runtimeexception-unable-to-instantiate-application/10158241#10158241) helps you out. – yorkw May 01 '12 at 23:24

6 Answers6

25

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

Community
  • 1
  • 1
JRaymond
  • 11,625
  • 5
  • 37
  • 40
  • Thanks for the tip with the cleanup! During the cleanup Eclipse had a problem to delete some old .jars... I deleted them manually and after rebuild the error disappeared. :) – Julia Hexen Nov 21 '12 at 17:17
  • This error occurs while using Intellij IDEA, so it's not the Eclipse bug for sure. – lomza Jan 16 '13 at 10:33
  • I can confirm this happens while running in ANDROID STUDIO Intellij IDEA – Maxrunner Nov 25 '13 at 11:28
3

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.

Timmmm
  • 88,195
  • 71
  • 364
  • 509
  • 3
    yeah this is driving me nuts too. It boggles my mind that with all of Googles resources (and investment in Android) why have they they not developed an IDE of their own which is more up to the standard of Xcode?? – wired00 Aug 20 '12 at 04:28
  • On the MacBook Pro I use at work I have to exit and restart Eclipse about 3x a day. That's just ridiculous !! Don't even get me started on how the performance turns to @#$% when editing XML files in Eclipse (Juno). – Someone Somewhere Sep 10 '13 at 20:42
  • 1
    @wired00 Thankfully we now have Android Studio. Phew! – edwoollard May 13 '15 at 23:24
  • @edwoollard true, true. I feel sorry for the old me back in 2012 haha – wired00 May 14 '15 at 00:03
  • @wired00 Hahahaha, so do I, for both of us! – edwoollard May 26 '15 at 04:59
1

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)

RicNjesh
  • 583
  • 10
  • 16
1

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.

Parmaia
  • 1,172
  • 1
  • 13
  • 28
  • I agree, I see it on 4.x devices and it doesn't break functionality. I tried force-stopping my app and it doesn't cause the exception, it only happens in Eclipse when I re-deploy the app to a 4.x device. – Someone Somewhere Sep 10 '13 at 20:39
1

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

martyglaubitz
  • 992
  • 10
  • 21
-2

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 <buildCommand> tag in this file.

Yogu
  • 9,165
  • 5
  • 37
  • 58
duongvanthai
  • 1,518
  • 1
  • 11
  • 14