-1

Just today I downloaded the eclipse and set it up for android development. When creating a new android project it creates appcompat_v7 library project which is referenced by the main project. The problem is that both show errors. I even tried to delete errors from the problems list but that did not help. A run time error was thrown -

04-25 15:07:51.521: E/AndroidRuntime(1348): FATAL EXCEPTION: main
04-25 15:07:51.521: E/AndroidRuntime(1348): Process: com.example.demo, PID: 1348
04-25 15:07:51.521: E/AndroidRuntime(1348): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.demo/com.example.demo.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.demo.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.demo-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.demo-1, /system/lib]]
04-25 15:07:51.521: E/AndroidRuntime(1348):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at android.os.Looper.loop(Looper.java:136)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at android.app.ActivityThread.main(ActivityThread.java:5017)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at java.lang.reflect.Method.invokeNative(Native Method)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at java.lang.reflect.Method.invoke(Method.java:515)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at dalvik.system.NativeStart.main(Native Method)
04-25 15:07:51.521: E/AndroidRuntime(1348): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.demo.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.demo-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.demo-1, /system/lib]]
04-25 15:07:51.521: E/AndroidRuntime(1348):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
04-25 15:07:51.521: E/AndroidRuntime(1348):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
04-25 15:07:51.521: E/AndroidRuntime(1348):     ... 11 more

How do I use the development environment now. Apparently I can't create a new project. But older ones are working just fine. Thanks in advance.

Edit: I am appending the first activity source that was created by the IDE -

package com.example.demo;

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment())
                    .commit();
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
            return rootView;
        }
    }

}
Pankaj Agarwal
  • 117
  • 1
  • 16

1 Answers1

0

I copied the android-support-v4.jar from libs folder to appcompat_v7/bin folder and the errors were resolved. The app ran just fine.

Pankaj Agarwal
  • 117
  • 1
  • 16