Unable to instantiate an Activity
<p>I have a problem that I am implementing application with spring android, I added a class in android:name attribute of Application tag of AndroidManifest file of Android project.
But it gives error that unable to instantiate an activity or ClassNotFoundException.</p>

<pre><code>error:
05-13 11:11:52.504: ERROR/AndroidRuntime(579): java.lang.RuntimeException: Unable to instantiate application org.shopzilla.android.MainApplication: java.lang.ClassNotFoundException: org.shopzilla.android.MainApplication in loader dalvik.system.PathClassLoader[/data/app/org.shopzilla.android.common-1.apk]
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at android.app.LoadedApk.makeApplication(LoadedApk.java:466)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3260)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at android.app.ActivityThread.access$2200(ActivityThread.java:117)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:969)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at android.os.Looper.loop(Looper.java:123)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at android.app.ActivityThread.main(ActivityThread.java:3683)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at java.lang.reflect.Method.invokeNative(Native Method)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at java.lang.reflect.Method.invoke(Method.java:507)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at dalvik.system.NativeStart.main(Native Method)
05-13 11:11:52.504: ERROR/AndroidRuntime(579): Caused by: java.lang.ClassNotFoundException: org.shopzilla.android.MainApplication in loader dalvik.system.PathClassLoader[/data/app/org.shopzilla.android.common-1.apk]
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at android.app.Instrumentation.newApplication(Instrumentation.java:942)
05-13 11:11:52.504: ERROR/AndroidRuntime(579):     at android.app.LoadedApk.makeApplication(LoadedApk.java:461)
</code></pre>

<p>Code: MyApplication.java</p>

<pre><code>package org.shopzilla.android.common;

import org.springframework.security.crypto.encrypt.AndroidEncryptors;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.sqlite.SQLiteConnectionRepository;
import org.springframework.social.connect.sqlite.support.SQLiteConnectionRepositoryHelper;
import org.springframework.social.connect.support.ConnectionFactoryRegistry;
import org.springframework.social.facebook.api.FacebookApi;
import org.springframework.social.facebook.connect.FacebookConnectionFactory;
import org.springframework.social.twitter.api.TwitterApi;
import org.springframework.social.twitter.connect.TwitterConnectionFactory;

import android.app.Application;
import android.database.sqlite.SQLiteOpenHelper;

public class MainApplication extends Application 
{
    private ConnectionFactoryRegistry _connectionFactoryRegistry;
    private SQLiteOpenHelper _repositoryHelper;
    private ConnectionRepository _connectionRepository; 


    //***************************************
    // Application Methods
    //***************************************





    @Override
    public void onCreate() 
    {
        // create a new ConnectionFactoryLocator and populate it with Facebook and Twitter ConnectionFactories
        _connectionFactoryRegistry = new ConnectionFactoryRegistry();
        _connectionFactoryRegistry.addConnectionFactory(new FacebookConnectionFactory(getFacebookAppId(), getFacebookAppSecret()));
        _connectionFactoryRegistry.addConnectionFactory(new TwitterConnectionFactory(getTwitterConsumerToken(), getTwitterConsumerTokenSecret()));

        // set up the database and encryption
        _repositoryHelper = new SQLiteConnectionRepositoryHelper(this);
        _connectionRepository = new SQLiteConnectionRepository(getLocalUserId(), _repositoryHelper, _connectionFactoryRegistry, AndroidEncryptors.text("password", "5c0744940b5c369b"));
    }


    //***************************************
    // Private methods
    //***************************************
    private String getLocalUserId()
    {
        return getString(R.string.local_user_id);
    }

    private String getFacebookAppId()
    {
        return getString(R.string.facebook_app_id);
    }

    private String getFacebookAppSecret()
    {
        return getString(R.string.facebook_app_secret);
    }

    private String getTwitterConsumerToken()
    {
        return getString(R.string.twitter_consumer_key);
    }

    private String getTwitterConsumerTokenSecret()
    {
        return getString(R.string.twitter_consumer_key_secret);
    }


    //***************************************
    // Public methods
    //***************************************
    public ConnectionRepository getConnectionRepository()
    {
        return _connectionRepository;
    }

    public FacebookConnectionFactory getFacebookConnectionFactory()
    {
        return (FacebookConnectionFactory) _connectionFactoryRegistry.getConnectionFactory(FacebookApi.class);
    }

    public TwitterConnectionFactory getTwitterConnectionFactory()
    {
        return (TwitterConnectionFactory) _connectionFactoryRegistry.getConnectionFactory(TwitterApi.class);
    }
}
</code></pre>
