ActionBarActivity: cannot be resolved to a type

hashDefine picture hashDefine · Sep 16, 2013 · Viewed 104.6k times · Source

I am new to android-programming. I am following this tutorial to add an ActionBar to my Main_Activity using the explanation in the "Support Android 2.1 and Above" section.

I followed this tutorial to add a Library-Project. Then after adding the library, at the point "Add the library to your application project: I felt lost .. basically because I don't have the "add" option by itself in my Eclipse ..

however I clicked on "add library" and moved on ..

now when I change Activity to ActionBarActivity :

public class MainActivity extends ActionBarActivity { ... }

in my mainActivity.java , it gives me error (a red line bellow the ActionBarActivity and all methods' names and some functions) .. and again when i change:

<activity android:theme="@style/Theme.AppCompat.Light" ... >

in the Manifest, it also give me an error saying: No resource found that matches the given name ..

I am totally lost .. what did I do wrong ?

Answer

Levite picture Levite · Jan 31, 2014

Check if you have a android-support-v4.jar file in YOUR project's lib folder, it should be removed!

In the tutorial, when you have followed the instructions of Adding libraries WITHOUT resources before doing the coorect Adding libraries WITH resources you'll get the same error.

(Don't know why someone would do something like that *lookingawayfrommyself* ^^)

So what did fix it in my case, was removing the android-support-v4.jar from YOUR PROJECT (not the android-support-v7-appcompat project), since this caused some kind of library collision (maybe because in the meantime there was a new version of the suport library).

Just another case, when this error might shows up.