Search code examples
androidandroid-activityclassloaderclassnotfoundexceptionruntimeexception

Android app fails to load on some phones in PathClassLoader


I have an app, let us call it 'com.company.foo', with a main Activity 'FooBar'. In my AndroidManifest.xml, I have

<application android:label="@string/app_name"
             android:icon="@drawable/icon"
             android:theme="@android:style/Theme.NoTitleBar.Fullscreen"  >
    <activity android:name="FooBar"
              android:label="@string/app_name"
              android:configChanges="keyboardHidden|orientation" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
...
</application>

(where the dots contain other activities inside my app). In this form, it works fine on my HTC desire and on the emulator. However, a (very) small number of people who downloaded the app from the market report a crash with

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.company.foo/com.company.foo.FooBar}: java.lang.ClassNotFoundException: com.company.foo.FooBar in loader dalvik.system.PathClassLoader[/mnt/asec/com.company.foo-1/pkg.apk]

Someone suggested to replace the android:name="FooBar" with android:name=".FooBar", which again works fine on my phone and the emulator, but fails on some other devices. If I leave this attribute out altogether it will not let me install at all.

Any ideas?


Solution

  • I have an app published on Android Market. And sometimes I receive similar crash reports. Seems that's not your fault. This can be reproduced if your app is installed on SD card. Eject this card without unmounting it and run your app.

    Additional information can be found here.