Sankar
Sankar

Reputation: 1691

Android App is crashing when installing through Eclipse

I get the following exception every time I reinstall my through eclipse. It happens every time I reinstall an app that is currently in the foreground.

I expect that this error is only happening during development because I cause an uninstallation of a running app through Eclipse.

Has anybody seen this error on user phones?

This started happening for me as I switched to a Galaxy Nexus with ICS.

02-22 11:31:07.098: E/AndroidRuntime(479): FATAL EXCEPTION: main
02-22 11:31:07.098: E/AndroidRuntime(479): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.app.LoadedApk.makeApplication(LoadedApk.java:466)
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3260)
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.app.ActivityThread.access$2200(ActivityThread.java:117)
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.os.Looper.loop(Looper.java:123)
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-22 11:31:07.098: E/AndroidRuntime(479):  at java.lang.reflect.Method.invokeNative(Native Method)
02-22 11:31:07.098: E/AndroidRuntime(479):  at java.lang.reflect.Method.invoke(Method.java:507)
02-22 11:31:07.098: E/AndroidRuntime(479):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-22 11:31:07.098: E/AndroidRuntime(479):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-22 11:31:07.098: E/AndroidRuntime(479):  at dalvik.system.NativeStart.main(Native Method)
02-22 11:31:07.098: E/AndroidRuntime(479): Caused by: java.lang.NullPointerException
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:346)
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.app.LoadedApk.getClassLoader(LoadedApk.java:291)
02-22 11:31:07.098: E/AndroidRuntime(479):  at android.app.LoadedApk.makeApplication(LoadedApk.java:458)
02-22 11:31:07.098: E/AndroidRuntime(479):  ... 11 more

In the above logs i didn't find any thing related to my application. But still it's crashing.

Can any one tell me what's the reason for this? Is this a bug in Ice Cream Sandwich of on the Galaxy Nexus?

Upvotes: 9

Views: 3957

Answers (3)

rf43
rf43

Reputation: 4405

You have a null pointer on line 346 in the initializeJavaContextClassLoader method.

02-22 11:31:07.098: E/AndroidRuntime(479): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:346)

Edit

Here is the method from the GrepCode/com.google.android/android/2.3_r1/ android.app.LoadedApk (starting at line 326)

private void initializeJavaContextClassLoader() {
    IPackageManager pm = ActivityThread.getPackageManager();
    android.content.pm.PackageInfo pi;
    try {
        pi = pm.getPackageInfo(mPackageName, 0);
    } catch (RemoteException e) {
        throw new AssertionError(e);
    }
    /*
     * Two possible indications that this package could be
     * sharing its virtual machine with other packages:
     *
     * 1.) the sharedUserId attribute is set in the manifest,
     *     indicating a request to share a VM with other
     *     packages with the same sharedUserId.
     *
     * 2.) the application element of the manifest has an
     *     attribute specifying a non-default process name,
     *     indicating the desire to run in another packages VM.
     */
    boolean sharedUserIdSet = (pi.sharedUserId != null);
    boolean processNameNotDefault =
            (pi.applicationInfo != null &&
            !mPackageName.equals(pi.applicationInfo.processName));
    boolean sharable = (sharedUserIdSet || processNameNotDefault);
    ClassLoader contextClassLoader =
            (sharable)
            ? new WarningContextClassLoader()
    : mClassLoader;
            Thread.currentThread().setContextClassLoader(contextClassLoader);
}

It looks like you might be trying to share a virtual machine with another package.

Upvotes: 0

Simon
Simon

Reputation: 14472

I had this problem recently but showing up in IDEA. I had to switch mid-project to Eclipse - ouch! I got no good answers on here an eventually, after I finished the project, I went back to IDEA and tried again. The final solution was to move the project out of my workspace, delete everything except my source and resources, then create a new project from existing sources. I wasted hours trying to figure this out and it might just work for you in Eclipse. Got to be worth a try...

Good luck

Upvotes: 0

Boe-Dev
Boe-Dev

Reputation: 1595

i got this problem when someting in XML is wrong, maybe you just have to regenerate your R.java

Upvotes: 1

Related Questions