方法一

jar包直接复制到lib中右击add as library,等自动构建完成后,打开build.gradle会发现dependencies中多了一个compile file('libs/***.jar');

方法二

新建一个管理包的Module,File->new Module->Android Library。

添加新建的包管理module,Project Structure,选中modules下面的项目,点击Dependencies,点击+号,选择Module Dependency,选择刚才新建的module。

拓展:

新建Android Library的包管理Module之后,Build项目,生成*.arr文件,复制到libs下面

在build.gradle中添加如下代码

android {
    repositories{
        flatdir{
            dirs 'libs'
        }
    }
}

dependencies {
    compile(name:"myadnroidlib",ext:"arr")
}

方法三(推荐)

使用仓库

Project中的build.gradle中配置仓库,使用jcenter仓库

allprojects {
    repositories {
        jcenter()
    }
}

在app的build.gradle中dependendies下输入compile "***",可以到对应工具包的官网中找gradle添加的语句,类似于maven

推荐用法

配置好仓库后,点击Project Structure,选中modules下面的项目,点击Dependencies,点击+号,选择Library Dependency,输入要加入的包

 

相关文章:

  • 2021-05-31
  • 2021-04-27
  • 2021-11-13
  • 2022-01-22
  • 2021-08-30
  • 2021-05-14
  • 2021-04-17
  • 2021-04-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-09-28
  • 2021-10-26
  • 2021-08-27
相关资源
相似解决方案