1

I followed the instructions indicated in other threads on how to import external libraries, but after importing android-support-v7-appcompat.jar into the Referenced Libraries of my Android project (in ADT v.22.0.5) I get java.lang.ClassNotFoundException:

import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;

public class MainActivity extends ActionBarActivity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        }
}

Can someone please shed some light?

enter image description here

Community
  • 1
  • 1
Javide
  • 2,477
  • 5
  • 45
  • 61

3 Answers3

10

Go the "Java Build Path" -> Order and export -> check all checkboxes -> clean -> build -> run

Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
0

You must add the class path to your new library.

You can see a file named .classpath, specify the path to your new library.

<classpathentry kind="lib" path="<path to your .jar file>"/>
Dileep
  • 5,362
  • 3
  • 22
  • 38
0

I fixed it following these instructions:

  1. How to set up ActionBarCompat in Eclipse

  2. How to implement Action Bar using ActionBarCompat

Javide
  • 2,477
  • 5
  • 45
  • 61