我正在使用eclipse和模拟器运行调试android应用程序,并且在重新启动应用程序时,我得到此异常,
03-23 02:19:51.384: E/AndroidRuntime(605): FATAL EXCEPTION: main
03-23 02:19:51.384: E/AndroidRuntime(605): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.ActivityThread.access$1300(ActivityThread.java:123)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.os.Looper.loop(Looper.java:137)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-23 02:19:51.384: E/AndroidRuntime(605): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 02:19:51.384: E/AndroidRuntime(605): at java.lang.reflect.Method.invoke(Method.java:511)
03-23 02:19:51.384: E/AndroidRuntime(605): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-23 02:19:51.384: E/AndroidRuntime(605): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-23 02:19:51.384: E/AndroidRuntime(605): at dalvik.system.NativeStart.main(Native Method)
03-23 02:19:51.384: E/AndroidRuntime(605): Caused by: java.lang.NullPointerException
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
03-23 02:19:51.384: E/AndroidRuntime(605): at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
03-23 02:19:51.384: E/AndroidRuntime(605): ... 11 more
但这并不能说明我的代码中发生错误的位置。知道为什么会发生这种情况以及如何预防吗?
这是小应用程序的完整清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.problemio"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ProblemioActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AddProblemActivity"
android:label="@string/add_problem" />
<activity
android:name=".LoginActivity"
android:label="@string/login" />
<activity
android:name=".MyProblemsActivity"
android:label="@string/your_problems" />
<activity
android:name=".LogoutActivity"
android:label="@string/app_name" />
<activity
android:name=".CreateProfileActivity"
android:label="@string/create_account" />
<activity
android:name=".ProblemActivity"
android:label="@string/problem_page_header" />
<activity
android:name=".SuggestSolutionActivity"
android:label="@string/suggest_solution_header" />
<activity
android:name=".SuggestedSolutionActivity"
android:label="@string/suggested_solution_header" />
<activity
android:name=".ViewSolutionsActivity"
android:label="@string/view_solutions_header" />
<activity
android:name=".TopicActivity"
android:label="@string/topic_header" />
</application>
</manifest>
谢谢!
答案 0 :(得分:1)
我也得到了这个例外。 我正在使用Nexus S,并更新到4.0.3 我只是忽略了这个例外。
答案 1 :(得分:0)
此问题的真正解决方案是文件夹权限问题。确保您在可以修改的文件夹中操作。我通过确保我在一个具有正确权限的文件夹中为我自己解决了同样的问题。