在 Android Studio 中添加外部库 [英] Adding external library in Android studio

查看:58
本文介绍了在 Android Studio 中添加外部库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加外部库 https://github.com/foursquare/foursquare-android-oauth 到我的 Android 应用程序(我使用 Android Studio,lib 作者为 Eclipse 提供的说明不适用于 Android Studio).

I want to add external library https://github.com/foursquare/foursquare-android-oauth to my Android application (I use Android Studio, the instructions provided by lib author for Eclipse didn't work for Android Studio).

我尝试用 maven 来做,所以在 File->Project Structure->Dependencies 我添加了 com.foursquare:foursquare-android-nativeoauth-lib:1.0.0 但是Gradle 同步失败:

I've tried to do it with maven, so in File->Project Structure->Dependencies I've added com.foursquare:foursquare-android-nativeoauth-lib:1.0.0 but Gradle Sync fails:

Error:Failed to find: com.foursquare:foursquare-android-nativeoauth-lib:1.0.0

当我尝试构建我的应用程序时(没有修复上述错误,因为我不知道如何)我得到:

When I try to build my app (without fixing above error becaus I don't know how) I get:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.foursquare:foursquare-android-nativeoauth-lib:1.0.0.
 Required by:
    ForSquaresOnly:app:unspecified
   > Could not parse POM http://jcenter.bintray.com/com/foursquare/foursquare-android-nativeoauth-lib/1.0.0/foursquare-android-nativeoauth-lib-1.0.0.pom
     > Could not find any version that matches com.foursquare:parent:1.0.0.

还有其他方法可以导入这个库吗?我可以简单地将源代码复制粘贴到我的源代码中或从中创建 JAR?

Any other way to import this lib? I can simply copy-paste source code into my source or create JAR out of it?

顺便说一句:如果遇到问题,请参阅此问题(导入后我遇到了此问题):清单合并失败:使用-sdk:minSdkVersion 14

BTW: if you run into problems see this question (I had this issue after importing): Manifest merger failed : uses-sdk:minSdkVersion 14

推荐答案

试试这个:

文件 > 项目结构 > 依赖项标签 > 添加模块依赖(scope = compile)

File > Project Structure > Dependencies Tab > Add module dependency (scope = compile)

其中模块依赖是项目库 Android 文件夹.

Where the module dependency is the project library Android folder.

这篇关于在 Android Studio 中添加外部库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆