简体   繁体   English

Appcompat /用android studio添加一个库

[英]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 它是AVD Manager图标左侧的图标

Hi everyone, 嗨,大家好,

I'm trying to use the appcompat-v7 with android studio. 我正在尝试使用appcompat-v7和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: 在build.gradle中但是当我尝试导入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. 它说我无法解析v7 ..当我检查文件夹外部lib时,只有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 .. Ps:它在另一个项目中工作,我可以在外部lib中看到lib,但它不想再这样做了..

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. 确认您已在SDK管理器中下载了最新的Android支持库和支持存储库。

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

Detailed tutorial on setting up the ActionBarActivity: 有关设置ActionBarActivity的详细教程:

http://www.blackcj.com/blog/2013/08/14/actionbar-with-android-support-library-r18/ 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. 添加blackcj避免在版本号中使用+它可能导致android studio上的不可预测和不可重复的构建,这可能会通过gradle导致更多的构建时间。 Thats expensive! 这太贵了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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