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 ?
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.
This way work for me with Eclipse in Android developer tool from Google -righ click - property - java build path - add external JAR
point to: android-support-v7-appcompat.jar in /sdk/extras/android/support/v7/appcompat/libs
Then
import android.support.v7.app.ActionBarActivity;
It does not sound like you imported the library right especially when you say at the point Add the library to your application project: I felt lost .. basically because I don't have the "add" option by itself .. however I clicked on "add library" and moved on ..
in eclipse you need to right click on the project, go to Properties, select Android in the list then Add to add the library
follow this tutorial in the docs
http://developer.android.com/tools/support-library/setup.html
I was also following the instructions on http://developer.android.com/training/basics/actionbar/setting-up.html
and even though I did everything in the tutorial, as soon as "extends Action" is changed to "extends ActionBarActivity" all sorts of errors appear in Eclipse, including the "ActionBarActivitycannot be resolved to a type"
None of the above solutions worked for me, but what did work is adding this line to the top:
import android.support.v7.app.ActionBarActivity;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With