0

I am running a debug android application with eclipse and the simulator, and on a restarting of the app, I get this exception,

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

But this doesn't really say where the error happened in my code. Any idea why this might be happening and how to prevent it?

and this is the entire manifest of the small application:

<?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>

Thanks!

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
GeekedOut
  • 16,905
  • 37
  • 107
  • 185
  • Do you have any Application on your solution? Did you declared the name on the Manifest? – Tiago Almeida Mar 23 '12 at 02:27
  • @Tiago There is actually a whole app that works despite this message....I'll also post the manifest. – GeekedOut Mar 23 '12 at 02:31
  • See http://stackoverflow.com/questions/9039017/android-app-application-cannot-be-instantiated-due-to-nullpointerexception. In that case cleaning the project fixed the prob..for whatever reason. Maybe this will help you too – 207 Mar 23 '12 at 02:57
  • @207 I thought cleaning the project was getting rid of errors. But in the solution's case, was it just a matter of adding this at the end of every inner class? EditEntry.this.finish(); – GeekedOut Mar 23 '12 at 03:09
  • @GeekedOut Yes. See the comments of that answer. Someone reproduced the problem and fixed it by cleaning. That NullPointer from LoadedApk.initializeJavaContextClassLoader seems to be quite popular – 207 Mar 23 '12 at 03:17

2 Answers2

1

I also get this excepiton. I am using Nexus S, and update to 4.0.3 I just ignore this exception.

hotpro
  • 336
  • 2
  • 3
  • I used to ignore it, but now I tried to release the app live and I am getting some errors while adding a key to the apk file and someone suggested I should clean out application errors so thats why I am cleaning it from the error. – GeekedOut Mar 23 '12 at 02:47
0

The real solution to this problem is a folder permissions issue. Make sure you are operating in a folder that you can modify. I just fixed that same problem for my self by making sure I was in a folder with the right permissions.

GeekedOut
  • 16,905
  • 37
  • 107
  • 185