通过Eclipse安装时,Android App崩溃了

San*_*kar 9 eclipse crash android

每次重新安装我的日蚀时,我都会收到以下异常.每次我重新安装当前位于前台的应用程序时都会发生这种情况.

我希望这个错误只发生在开发期间,因为我通过Eclipse卸载正在运行的应用程序.

有没有人在用户手机上看到此错误?

当我转向使用ICS的Galaxy Nexus时,这开始发生在我身上.

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
Run Code Online (Sandbox Code Playgroud)

在上面的日志中,我找不到任何与我的申请相关的东西.但它仍在崩溃.

谁能告诉我这是什么原因?这是Galaxy Nexus冰淇淋三明治中的一个错误吗?

rf4*_*f43 0

该方法的第 346 行有一个空指针initializeJavaContextClassLoader

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

编辑

这是来自GrepCode/com.google.android/android/2.3_r1/ android.app.LoadedApk的方法(从 开始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);
}
Run Code Online (Sandbox Code Playgroud)

看起来您可能正在尝试与另一个包共享虚拟机。

  • @DDoSAtack 我总是会责怪程序员而不是框架。导致此错误的仍然可能是应用程序设置中的错误。但空指针异常完全超出了程序员的范围。你的回答没有帮助。 (7认同)
  • 我没有在代码中的任何地方使用此方法。这个类在将 apk 加载到设备时使用,然后我在代码中为此做了什么。 (2认同)