简体   繁体   中英

LogCat outputs Null Pointer Exceptions, but app isn't crashing

When starting my app, my LogCat fills up with this

06-11 23:51:51.635: E/AndroidRuntime(29950): FATAL EXCEPTION: main
06-11 23:51:51.635: E/AndroidRuntime(29950): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4201)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.app.ActivityThread.access$1300(ActivityThread.java:140)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1287)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.os.Looper.loop(Looper.java:137)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.app.ActivityThread.main(ActivityThread.java:4898)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at java.lang.reflect.Method.invokeNative(Native Method)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at java.lang.reflect.Method.invoke(Method.java:511)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at dalvik.system.NativeStart.main(Native Method)
06-11 23:51:51.635: E/AndroidRuntime(29950): Caused by: java.lang.NullPointerException
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:377)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.app.LoadedApk.getClassLoader(LoadedApk.java:320)
06-11 23:51:51.635: E/AndroidRuntime(29950):    at android.app.LoadedApk.makeApplication(LoadedApk.java:493)
06-11 23:51:51.635: E/AndroidRuntime(29950):    ... 11 more

Manifest (Added the manifest, just like you asked)

<?xml version="1.0" encoding="utf-8"?>
<manifest package="eu.hantaro.www"
    android:versionCode="1"
    android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="16" />

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="eu.hantaro.www.permission.MAPS_RECEIVE" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />



    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/spui" >
        <activity
            android:name="eu.hantaro.www.SplashScreen"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity 
            android:name="eu.hantaro.www.FavoriteActivity"
            android:screenOrientation="portrait">            
        </activity>

        <activity 
            android:name="eu.hantaro.www.lightTimesActivity"
            android:screenOrientation="portrait">            
        </activity>

        <activity 
            android:name="eu.hantaro.www.MainActivity"
            android:screenOrientation="portrait">
        </activity>

        <activity 
            android:name="eu.hantaro.www.buildingDetailsActivity"
            android:screenOrientation="portrait">            
        </activity>


        <activity 
            android:name="eu.hantaro.www.SettingsActivity"
            android:screenOrientation="portrait">            
        </activity>

        <activity 
            android:name="eu.hantaro.www.SubbuildingActivity"
            android:screenOrientation="portrait">            
        </activity>

        <activity 
            android:name="eu.hantaro.www.Addbuilding"
            android:screenOrientation="portrait">            
        </activity>

        <activity 
            android:name="eu.hantaro.www.lightSettingsActivity"
            android:screenOrientation="portrait">            
        </activity>

        <activity 
            android:name="eu.hantaro.www.DirectionActivity"
            android:screenOrientation="portrait">            
        </activity>

        <activity 
            android:name="eu.hantaro.www.SearchAddressActivity"
            android:screenOrientation="portrait">            
        </activity>

        <activity 
            android:name="eu.hantaro.www.tutorialActivity"
            android:screenOrientation="portrait">            
        </activity>

          <activity 
            android:name="eu.hantaro.www.tutorialContentActivity"
            android:screenOrientation="portrait">            
        </activity>

         <activity 
            android:name="eu.hantaro.www.SharedPref"
            android:screenOrientation="portrait">            
        </activity>

          <activity 
            android:name="eu.hantaro.www.buildingList"
            android:screenOrientation="portrait">            
        </activity>


        <service android:name="eu.hantaro.www.lightTimeService" />
        <service android:name="eu.hantaro.www.NotificationF" />
        <service android:name="eu.hantaro.www.NotificationD" />
        <service android:name="eu.hantaro.www.NotificationA" />
        <service android:name="eu.hantaro.www.NotificationM" />
        <service android:name="eu.hantaro.www.NotificationI" />
        <service android:name="eu.hantaro.www.RingerModeSilent" />
        <service android:name="eu.hantaro.www.RingerModeNormal" />

        <uses-library android:name="com.google.android.maps" />
    </application>    
</manifest>

But the app doesn't crash, everything is just working fine. What does it mean the things my LogCat is throwing at me?

Looked into the ICS source code - It seems like for whatever reason the Package Manager can't get your package info - it could just be an eclipse/ADT bug where eclipse holds some kind of lock on the file, but whatever it is, it doesn't seem like something that you could cause with your code. I would suggest running a clean, uninstalling the app from the emulator/device, or if those don't work, you might try a fresh eclipse workspace.

Another thing that might be an issue is if you're using a Library project - try unlinking the two, cleaning, and then linking them back up again - but thats it for my bag o' tricks :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM