转载请标明出处,维权必究:http://77blogs.com/?p=496
android中引用的包一般分为两种:
1、jar包
2、aar包
arr包其实带有res的jar包,而普通的jar包是不带资源文件的。那么如何在项目中引用呢?
1、将aar包复制到libs目录下
2、在build.gradle文件中添加一个本地仓库,并把libs目录作为仓库的地址。
1 |
repositories {flatDir {dirs 'libs'}} |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
android{ . . . repositories { flatDir { dirs 'libs' } } . . . } |
3、在build.gradle文件中dependencies标签中添加下面的依赖。
1 2 3 4 |
dependencies { api fileTree(dir: 'libs', include: '*.jar') implementation (name:’你的aar名字’, ext:’aar’) } |
若是整个项目都要用到aar包
则用api (name:’你的aar名字’, ext:’aar’)