简体   繁体   中英

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 ..

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/

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM