[Android Studio] *.jar 与 *.aar 的生成与*.aar导入项目方法
主要讲解Android Studio中生成aar文件以及本地方式使用aar文件的方法。
http://bbs.28tui.com/thread-7490461-1-1.html
http://bbs.28tui.com/thread-7490445-1-1.html
http://bbs.28tui.com/thread-7490430-1-1.html
http://bbs.28tui.com/thread-7490411-1-1.html
http://bbs.28tui.com/thread-7490386-1-1.html
http://bbs.28tui.com/thread-7490367-1-1.html
http://bbs.28tui.com/thread-7490347-1-1.html
http://bbs.28tui.com/thread-7490347-1-1.html
http://bbs.28tui.com/thread-7490328-1-1.html
http://bbs.28tui.com/thread-7490308-1-1.html
http://bbs.28tui.com/thread-7490288-1-1.html
http://bbs.28tui.com/thread-7490272-1-1.html
http://bbs.28tui.com/thread-7490252-1-1.html
http://bbs.28tui.com/thread-7490237-1-1.html
http://bbs.28tui.com/thread-7490223-1-1.html
http://bbs.28tui.com/thread-7490210-1-1.html
http://bbs.28tui.com/thread-7490190-1-1.html
http://bbs.28tui.com/thread-7490174-1-1.html
http://bbs.28tui.com/thread-7490092-1-1.html
http://bbs.28tui.com/thread-7490063-1-1.html
http://bbs.28tui.com/thread-7490025-1-1.html
http://bbs.28tui.com/thread-7491764-1-1.html
http://bbs.28tui.com/thread-7491780-1-1.html
http://bbs.28tui.com/thread-7491792-1-1.html
http://bbs.28tui.com/thread-7491804-1-1.html
http://bbs.28tui.com/thread-7491814-1-1.html
http://bbs.28tui.com/thread-7491831-1-1.html
http://bbs.28tui.com/thread-7491841-1-1.html
http://bbs.28tui.com/thread-7491849-1-1.html
http://bbs.28tui.com/thread-7491863-1-1.html
http://bbs.28tui.com/thread-7491868-1-1.html
http://bbs.28tui.com/thread-7491884-1-1.html
http://bbs.28tui.com/thread-7491896-1-1.html
http://bbs.28tui.com/thread-7491905-1-1.html
http://bbs.28tui.com/thread-7491927-1-1.html
http://bbs.28tui.com/thread-7491934-1-1.html
http://bbs.28tui.com/thread-7491950-1-1.html
http://bbs.28tui.com/thread-7491967-1-1.html
http://bbs.28tui.com/thread-7491985-1-1.html
http://bbs.28tui.com/thread-7491996-1-1.html
http://bbs.28tui.com/thread-7492009-1-1.html
http://bbs.28tui.com/thread-7494542-1-1.html
http://bbs.28tui.com/thread-7495794-1-1.html
http://bbs.28tui.com/thread-7495810-1-1.html
http://bbs.28tui.com/thread-7495968-1-1.html
http://bbs.28tui.com/thread-7495972-1-1.html
http://bbs.28tui.com/thread-7495987-1-1.html
http://bbs.28tui.com/thread-7495991-1-1.html
http://bbs.28tui.com/thread-7496001-1-1.html
http://bbs.28tui.com/thread-7496014-1-1.html
http://bbs.28tui.com/thread-7496119-1-1.html
http://bbs.28tui.com/thread-7496144-1-1.html
http://bbs.28tui.com/thread-7496166-1-1.html
http://bbs.28tui.com/thread-7496185-1-1.html
http://bbs.28tui.com/thread-7496316-1-1.html
http://bbs.28tui.com/thread-7497935-1-1.html
http://bbs.28tui.com/thread-7498038-1-1.html
http://bbs.28tui.com/thread-7498041-1-1.html
http://bbs.28tui.com/thread-7501173-1-1.html
http://bbs.28tui.com/thread-7501157-1-1.html
http://bbs.28tui.com/thread-7501173-1-1.html
http://bbs.28tui.com/thread-7501186-1-1.html
http://bbs.28tui.com/thread-7508001-1-1.html
http://bbs.28tui.com/thread-7508014-1-1.html
http://bbs.28tui.com/thread-7508041-1-1.html
http://bbs.28tui.com/thread-7508067-1-1.html
http://bbs.28tui.com/thread-7508079-1-1.html
http://bbs.28tui.com/thread-7508141-1-1.html
http://bbs.28tui.com/thread-7508160-1-1.html
http://bbs.28tui.com/thread-7508242-1-1.html
http://bbs.28tui.com/thread-7508300-1-1.html
http://bbs.28tui.com/thread-7508382-1-1.html
http://bbs.28tui.com/thread-7508404-1-1.html
http://bbs.28tui.com/thread-7508404-1-1.html
http://bbs.28tui.com/thread-7509181-1-1.html
http://bbs.28tui.com/thread-7509200-1-1.html
http://bbs.28tui.com/thread-7509265-1-1.html
http://bbs.28tui.com/thread-7509279-1-1.html
http://bbs.28tui.com/thread-7509332-1-1.html
http://bbs.28tui.com/thread-7509357-1-1.html
http://bbs.28tui.com/thread-7509372-1-1.html
http://bbs.28tui.com/thread-7510720-1-1.html
http://bbs.28tui.com/thread-7509404-1-1.html
http://bbs.28tui.com/thread-7510858-1-1.html
http://bbs.28tui.com/thread-7510720-1-1.html
http://bbs.28tui.com/thread-7510869-1-1.html
http://bbs.28tui.com/thread-7519896-1-1.html
http://bbs.28tui.com/thread-7519905-1-1.html
http://bbs.28tui.com/thread-7519972-1-1.html
http://bbs.28tui.com/thread-7519989-1-1.html
http://bbs.28tui.com/thread-7519997-1-1.html
http://bbs.28tui.com/thread-7520005-1-1.html
http://bbs.28tui.com/thread-7520013-1-1.html
http://bbs.28tui.com/thread-7520024-1-1.html
http://bbs.28tui.com/thread-7548297-1-1.html
http://bbs.28tui.com/thread-7548601-1-1.html
http://bbs.28tui.com/thread-7548667-1-1.html
http://bbs.28tui.com/thread-7548713-1-1.html
http://bbs.28tui.com/thread-7548728-1-1.html
http://bbs.28tui.com/thread-7548737-1-1.html
http://bbs.28tui.com/thread-7548754-1-1.html
http://bbs.28tui.com/thread-7548754-1-1.html
http://bbs.28tui.com/thread-7548761-1-1.html
http://bbs.28tui.com/thread-7548773-1-1.html
http://bbs.28tui.com/thread-7548788-1-1.html
http://bbs.28tui.com/thread-7548796-1-1.html
http://bbs.28tui.com/thread-7548808-1-1.html
http://bbs.28tui.com/thread-7548820-1-1.html
http://bbs.28tui.com/thread-7548827-1-1.html
http://bbs.28tui.com/thread-7548827-1-1.html
http://bbs.28tui.com/thread-7548843-1-1.html
http://bbs.28tui.com/thread-7548857-1-1.html
http://bbs.28tui.com/thread-7549270-1-1.html
http://bbs.28tui.com/thread-7549325-1-1.html
http://bbs.28tui.com/thread-7549533-1-1.html
http://bbs.28tui.com/thread-7549545-1-1.html
http://bbs.28tui.com/thread-7549551-1-1.html
http://bbs.28tui.com/thread-7549803-1-1.html
http://bbs.28tui.com/thread-7549835-1-1.html
http://bbs.28tui.com/thread-7549904-1-1.html
http://bbs.28tui.com/thread-7549929-1-1.html
http://bbs.28tui.com/thread-7549936-1-1.html
http://bbs.28tui.com/thread-7549947-1-1.html
http://bbs.28tui.com/thread-7549968-1-1.html
http://bbs.28tui.com/thread-7549980-1-1.html
http://bbs.28tui.com/thread-7549985-1-1.html
http://bbs.28tui.com/thread-7550007-1-1.html
http://bbs.28tui.com/thread-7550021-1-1.html
http://bbs.28tui.com/thread-7550028-1-1.html
http://bbs.28tui.com/thread-7550043-1-1.html
http://bbs.28tui.com/thread-7550059-1-1.html
http://bbs.28tui.com/thread-7550254-1-1.html
http://bbs.28tui.com/thread-7550264-1-1.html
http://bbs.28tui.com/thread-7551394-1-1.html
http://bbs.28tui.com/thread-7551406-1-1.html
http://bbs.28tui.com/thread-7551421-1-1.html
http://bbs.28tui.com/thread-7551430-1-1.html
http://bbs.28tui.com/thread-7551443-1-1.html
http://bbs.28tui.com/thread-7551454-1-1.html
http://bbs.28tui.com/thread-7551462-1-1.html
http://bbs.28tui.com/thread-7551475-1-1.html
http://bbs.28tui.com/thread-7551535-1-1.html
http://bbs.28tui.com/thread-7551586-1-1.html
http://bbs.28tui.com/thread-7551596-1-1.html
http://bbs.28tui.com/thread-7551601-1-1.html
http://bbs.28tui.com/thread-7551642-1-1.html
http://bbs.28tui.com/thread-7551651-1-1.html
http://bbs.28tui.com/thread-7551661-1-1.html
http://bbs.28tui.com/thread-7551670-1-1.html
http://bbs.28tui.com/thread-7551678-1-1.html
http://bbs.28tui.com/thread-7552320-1-1.html
http://bbs.28tui.com/thread-7552329-1-1.html
http://bbs.28tui.com/thread-7552401-1-1.html
http://bbs.28tui.com/thread-7553200-1-1.html
http://bbs.28tui.com/thread-7553213-1-1.html
http://bbs.28tui.com/thread-7553229-1-1.html
http://bbs.28tui.com/thread-7553229-1-1.html
http://bbs.28tui.com/thread-7553240-1-1.html
http://bbs.28tui.com/thread-7553253-1-1.html
http://bbs.28tui.com/thread-7553261-1-1.html
http://bbs.28tui.com/thread-7553277-1-1.html
http://bbs.28tui.com/thread-7553286-1-1.html
http://bbs.28tui.com/thread-7553301-1-1.html
http://bbs.28tui.com/thread-7553313-1-1.html
http://bbs.28tui.com/thread-7553328-1-1.html
http://bbs.28tui.com/thread-7553345-1-1.html
http://bbs.28tui.com/thread-7553357-1-1.html
http://bbs.28tui.com/thread-7553377-1-1.html
http://bbs.28tui.com/thread-7553393-1-1.html
http://bbs.28tui.com/thread-7553411-1-1.html
http://bbs.28tui.com/thread-7554767-1-1.html
http://bbs.28tui.com/thread-7554996-1-1.html
http://bbs.28tui.com/thread-7555013-1-1.html
http://bbs.28tui.com/thread-7555028-1-1.html
http://bbs.28tui.com/thread-7555040-1-1.html
http://bbs.28tui.com/thread-7555050-1-1.html
http://bbs.28tui.com/thread-7555065-1-1.html
http://bbs.28tui.com/thread-7555078-1-1.html
http://bbs.28tui.com/thread-7555091-1-1.html
http://bbs.28tui.com/thread-7555106-1-1.html
http://bbs.28tui.com/thread-7555115-1-1.html
http://bbs.28tui.com/thread-7555130-1-1.html
http://bbs.28tui.com/thread-7555138-1-1.html
http://bbs.28tui.com/thread-7555150-1-1.html
http://bbs.28tui.com/thread-7555160-1-1.html
http://bbs.28tui.com/thread-7555173-1-1.html
http://bbs.28tui.com/thread-7555192-1-1.html
http://bbs.28tui.com/thread-7555200-1-1.html
http://bbs.28tui.com/thread-7555213-1-1.html
http://bbs.28tui.com/thread-7555223-1-1.html
http://bbs.28tui.com/thread-7562270-1-1.html
http://bbs.28tui.com/thread-7562277-1-1.html
http://bbs.28tui.com/thread-7562294-1-1.html
http://bbs.28tui.com/thread-7562304-1-1.html
http://bbs.28tui.com/thread-7562316-1-1.html
http://bbs.28tui.com/thread-7562327-1-1.html
http://bbs.28tui.com/thread-7562336-1-1.html
http://bbs.28tui.com/thread-7562342-1-1.html
http://bbs.28tui.com/thread-7562470-1-1.html
http://bbs.28tui.com/thread-7562475-1-1.html
http://bbs.28tui.com/thread-7562481-1-1.html
http://bbs.28tui.com/thread-7562504-1-1.html
http://bbs.28tui.com/thread-7562508-1-1.html
http://bbs.28tui.com/thread-7562518-1-1.html
http://c.tieba.baidu.com/p/3353428691
http://c.tieba.baidu.com/p/3351859852
http://c.tieba.baidu.com/p/3353421523
http://c.tieba.baidu.com/p/3322105873
http://c.tieba.baidu.com/p/3333294471
http://c.tieba.baidu.com/p/3328592309
http://c.tieba.baidu.com/p/3353474321
http://c.tieba.baidu.com/p/3353474321
http://c.tieba.baidu.com/p/3352251851
http://c.tieba.baidu.com/p/3352098695
http://c.tieba.baidu.com/p/3350722055
http://c.tieba.baidu.com/p/3347824503
http://c.tieba.baidu.com/p/3347825380
http://c.tieba.baidu.com/p/3347825863
http://c.tieba.baidu.com/p/3322349124
http://c.tieba.baidu.com/p/3322348327
http://c.tieba.baidu.com/p/3322449810
http://c.tieba.baidu.com/p/3322204659
http://c.tieba.baidu.com/p/3317721878
http://c.tieba.baidu.com/p/3321949895
http://c.tieba.baidu.com/p/3310520585
http://c.tieba.baidu.com/p/3350722055
在Android Studio中对一个自己库进行生成操作时将会同时生成*.jar与*.aar文件。
分别存储位置:
*.jar:库/build/intermediates/bundles/debug(release)/classes.jar
*.aar:库/build/outputs/aar/libraryname.aar
两者区别:
*.jar:只包含了class文件与清单文件,不包含资源文件,如图片等所有res中的文件。
*.aar:包含所有资源,class以及res资源文件全部包含
如果你只是一个简单的类库那么使用生成的*.jar文件即可;如果你的是一个UI库,包含一些自己写的控件布局文件以及字体等资源文件那么就只能使用*.aar文件。
使用方式:
*.jar:拷贝到:libs目录,eclipse直接导入即可,AndroidStudio项目中添加:
1
2
3
|
dependencies {
compile fileTree(include: [‘*.jar‘], dir:‘libs‘)
}
|
*.aar:有两种方式,分别为本地加载以及网络加载,由于网络加载涉及到发布到mavenCentral托管的问题这里不做讨论;另外eclipse很久没有使用了也不做讨论;在这里给大家说一种本地加载的方式,简单快捷。
这里演示的aar文件为:”genius.aar“
第一步:拷贝到:libs目录
第二步:build.gradle 配置文件中更改为
1
2
3
4
5
6
7
8
|
repositories {
flatDir {
dirs‘libs‘
}
}
dependencies {
compile(name:‘genius‘, ext:‘aar‘)
}
|
分别添加了”repositories“与更改了”dependencies“,然后重新编译一次项目就可以正常使用了。
这时打开你的项目地址”\build\intermediates\exploded-aar\“你会发现下面多了一个文件夹”genius“打开后能看见里边包含了一个”classes.jar“文件与一些资源文件和”R.txt“文件。
这就是Android Studio自动解析了aar文件后出现的东西。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。