每次重新安装我的日蚀时,我都会得到以下异常。 每次我重新安装当前位于前台的应用程序时都会发生这种情况。
我希望此错误仅在开发期间发生,因为我通过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
在上面的日志中,我找不到与我的申请有关的任何内容。但它仍在崩溃。
任何人都可以告诉我这是什么原因吗?这是Galaxy Nexus冰淇淋三明治中的一个错误吗?
答案 0 :(得分:1)
当XML中的某些内容出错时,我遇到了这个问题,也许你只需要重新生成你的R.java
答案 1 :(得分:0)
initializeJavaContextClassLoader
方法中的第346行有一个空指针。
02-22 11:31:07.098: E/AndroidRuntime(479): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:346)
修改
以下是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);
}
看起来您可能正在尝试与其他软件包共享虚拟机。
答案 2 :(得分:0)
我最近遇到了这个问题但是出现在IDEA中。我不得不将项目中期切换到Eclipse - 哎哟!我最终在这里没有得到很好的答案,在我完成项目后,我回到了IDEA并再次尝试。最终的解决方案是将项目移出我的工作区,删除除源和资源之外的所有内容,然后从现有源创建一个新项目。我浪费了几个小时试图解决这个问题,它可能只适用于Eclipse。值得一试......
祝你好运