Android studio 怎么打包成aar包和引用aar包

目录

1.首先什么是aar格式

2. 怎么把一个模块编译成一个aar

首先把鼠标放到要编译的模块上

然后再点击:Build ->Build  Module 'xxx' 刚刚鼠标选的模块

最后生成的aar包在这里

3. 怎么引用aar包

例如我把我刚刚编译的aar包放到 我要引用的app/build/libs/xx.aar

修改这个APP 的build.grade


 

1.首先什么是aar格式

看看官网的说明:

http://tools.android.com/tech-docs/new-build-system/aar-format/

The 'aar' bundle is the binary distribution of an Android Library Project.

 
The file extension is .aar, and the maven artifact type should be aar as well, but the file itself a simple zip file with the following entries:
  • /AndroidManifest.xml (mandatory)
  • /classes.jar (mandatory)
  • /res/ (mandatory)
  • /R.txt (mandatory)
  • /assets/ (optional)
  • /libs/*.jar (optional)
  • /jni/<abi>/*.so (optional)
  • /proguard.txt (optional)
  • /lint.jar (optional)
These entries are directly at the root of the zip file.
 
也就是说是相当于Android工程里的一个module 打包成一个aar的压缩包模式
 

2. 怎么把一个模块编译成一个aar

首先把鼠标放到要编译的模块上

然后再点击:Build ->Build  Module 'xxx' 刚刚鼠标选的模块

最后生成的aar包在这里

3. 怎么引用aar包

例如我把我刚刚编译的aar包放到 我要引用的app/build/libs/xx.aar

修改这个APP 的build.grade

新加如下:

然后再Mainactivity.java 里面引用aar中的class啦

import com.xx.TAInterface;

 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值