Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appcompat / add a library with android 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 ..

like image 463
nsvir Avatar asked Aug 21 '13 17:08

nsvir


2 Answers

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/

like image 68
blackcj Avatar answered Oct 15 '22 10:10

blackcj


To add on blackcj Avoid using + in versions numbers it can lead to unpredictable and unrepeatable builds on android studio this may lead to more build time by gradle. Thats expensive!

like image 20
Victor Michael Avatar answered Oct 15 '22 10:10

Victor Michael