Android – Appcompat / add a library with android studio

androidandroid-appcompatandroid-studio

[Fixed] When you have added your dependencies you need to sync your project. It's the icon on the left of AVD Manager icon

Hi everyone,

I'm trying to use the appcompat-v7 with android studio.
I add those lines:

dependencies {
    compile 'com.android.support:appcompat-v7:18.0.+'
}

In the build.gradle but when I try to import the lib:

import android.support.v7.app.ActionBar;

It says me that cannot resolve v7 .. And when I check the folder external lib there is only support-v4.

Did I miss something ?

Ps: It worked in an other project and I could see the lib in external lib but it don't want do it again ..

Best Answer

You should have two dependencies:

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
    compile 'com.android.support:appcompat-v7:18.0.+'
}

Verify that you have downloaded the latest Android Support Library and Support Repository within your SDK manager.

http://developer.android.com/tools/support-library/setup.html#download

Detailed tutorial on setting up the ActionBarActivity:

http://www.blackcj.com/blog/2013/08/14/actionbar-with-android-support-library-r18/