Question

I'm getting the following error:

E/AndroidRuntime(1840): java.lang.RuntimeException: Unable to instantiate application com.mypackage.ui.misc.MyApplication: java.lang.ClassNotFoundException: com.mypackage.ui.misc.MyApplication in loader dalvik.system.PathClassLoader[/data/app/com.mypackage-2.apk]

My manifest looks like this:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.mypackage"
        android:versionCode="1"
        android:versionName="1.0">
...
    <application
        android:name=".ui.misc.MyApplication"
        android:icon="@drawable/launcher"
        android:label="@string/app_name"
        android:theme="@style/MyTheme" > 
...

I should mention that this is happening on Mac OS X Lion. I've tried to run the app both on an emulator and a couple of Android devices and if always failed with the same error.

I looked at this solution, but my class is located at com.mypackage.ui.misc.MyApplication and it extends android.app.Application so it doesn't apply.

Anybody else ran into this weird error? Any ideas on how to fix it?

UPDATE: Ran into the same problem on Ubuntu, with the same project.

Was it helpful?

Solution

It turnes out the problem I was having had to do with a couple of libraries I was using. The libraries were included in the Java Build Path but not in the Android references. Adding them as references to the Android properties fixed the problem:

Right-click on the project -> choose Properties -> click on Android -> add the libraries in the Libraries section.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top