Reputation: 1
It seems like a very common issue. I'm trying to import and run an Android app in latest Eclipse (neon), but I get the common error of The import android.support.v7.app.AppCompatActivity cannot be resolved
. I've downloaded the library project android-support-v7-appcompat
from somewhere, and linked it to the project properties. But the errors still here. I see v4 ActivityCompat
is not throwing any errors, but the v7 AppCompatActivity
shows error, which seems strange. How should I fix it? I am using Android API 23.
I already have the support libraries of SDK installed. But when I add the .jar
libraries (which are just two, one for source, one for javadoc), still nothing happens.
import android.support.v4.app.ActivityCompat; --> This is ok
import android.support.v7.app.AppCompatActivity; --> This shows error!
Upvotes: 2
Views: 3029
Reputation: 1007399
I see v4 ActivityCompat is not throwing any errors, but the v7 AppCompatActivity shows error, which seems strange.
Not especially. The random files you grabbed from some random place do not have this class, apparently. AppCompatActivity
was added sometime after appcompat-v7
was published as a library, as a long-term replacement for the former ActionBarActivity
. Presumably, the random files you grabbed from some random place pre-date this change.
How should I fix it?
Switch to an AAR-aware build system and an IDE that supports it. Then, depend upon the appcompat-v7
AAR, which is the only way that appcompat-v7
is being distributed at the present time.
Or, do not use appcompat-v7
(or pretty much anything else from the Android Support Library, as most, if not all, of the packages are distributed as AARs, not JARs).
Upvotes: 3