如何将库项目(如Sherlock ABS)添加到Android Studio?
(不适用于旧的基于ADT Eclipse的捆绑包,而是适用于新的Android Studio。)
如何将库项目(如Sherlock ABS)添加到Android Studio?
(不适用于旧的基于ADT Eclipse的捆绑包,而是适用于新的Android Studio。)
当前回答
将其添加到构建渐变文件中:
dependencies {
implementation 'com.jakewharton:butterknife:9.0.0'
}
其他回答
你可以很容易地做到这一点。转到菜单文件->新建->导入模块…:
浏览包含模块的目录。单击“完成”:
转到项目结构并添加模块依赖项:
注意:如果您收到SDK错误,请更新该错误。
使用菜单“文件”->“项目结构”->“模块”。
我今天开始使用它。这有点不同。
对于Sherlock,您可能希望删除他们的测试目录,或者将junit.jar文件添加到类路径中。
要使用gradle导入库,必须将其添加到build.gradle(模块的一个)的dependencies部分。
E.g.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
}
Android Studio正在发生变化。
如果您右键单击Android项目部分中的模块文件夹Studio(我使用的是0.2.10版本)。
按F4显示项目结构,单击库或全局库,然后单击+添加JAR文件。单击Modules what you want add jar,选择Dependencies选项卡,单击+,然后添加Library。
打开构建gradle模块应用程序文件并添加依赖项。如果您下载了库,只需导入并构建为grade。
否则,在侧渐变模块应用程序中添加存储库:
repositories {
maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
}
第一个存储库将为您下载库。
并编译下载的库:
compile ('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
transitive = true
}
如果要创建库,只需将项目作为导入新模块导入即可。
在导入ABS模块(从文件>项目结构)并确保其具有Android 2.2和Support Library v4作为依赖项后,我仍然收到以下错误,因为您@Alex
Error retrieving parent for item: No resource found that matches the given name 'Theme.Sherlock.Light.DarkActionBar'
我将新导入的模块作为依赖项添加到我的主应用程序模块中,这解决了问题。