android - 如何在Android Studio中使用导入的库项目?

标签 android android-studio

我按照本指南导入了库项目:https://stackoverflow.com/a/20497933现在我有一个包含我所需库的 libs 文件夹。

但是我如何在我的代码中使用它。我无法导入 com.github.whateverlibrary,也无法使用 com.mypackagename.whateverlibrary

如何在我的项目中引用这个本地库?

编辑:

我的 settings.gradle 文件:

include ':libs:MyLibrary'

我的 app.gradle 文件:

compile fileTree(include: ['MyLibrary'], dir: 'libs')

最佳答案

要从列为依赖项的库中添加导入,请使用类的完全限定名称。例如,要从 https://github.com/bumptech/glide 导入,您将使用库中的名称,无需任何修改,例如添加 com.githubcom.yourpackagename
要将 Glide 导入到您的类中,您可以使用

import com.bumptech.glide.Glide;

参见 sample projects为了更好的理解

关于android - 如何在Android Studio中使用导入的库项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38190431/

相关文章:

android - 如何在按钮单击时调用或弹出 fragment

android - parseSdkContent 失败安卓

android - 如何在 Canvas 上将 onclicklistener 设置为 Drawable?

安卓工作室 : Error:Cause: unable to find valid certification path to requested target

android-studio - Intellij IDEA 无法 ctrl + v 'Create New Class' 的名称

android - Gradle 获取当前构建类型

android studio ctrl + space 打开文档窗口

php - Base64 -> AJAX -> PHP 在 Android 股票浏览器上写入 0 字节文件

安卓 :app:transformClassesWithJarMergingForDebug FAILED - ZipException: duplicate entry

android - java.lang.IllegalStateException : commit already called in view pager with Tablayout