Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
253 views
in Technique[技术] by (71.8m points)

java - ActionBarActivity: cannot be resolved to a type

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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...