gradle 打包aar去除引用的jar文件

在写libs module的时候,打包的arr的realese版本是包含libs目录下的文件,这时候你引入这个aar,可能会和你现有引入的jar文件冲突,

在打包aar的时候可以设置不引入libs文件,很简单

看一下你的lib module的gradle文件,里面应该有下面这样一段

dependencies {

compile fileTree(include: ['*.jar'],dir:'libs')

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {

excludegroup:'com.android.support',module:'support-annotations'

})

compile'com.android.support:appcompat-v7:24.2.1'

testCompile'junit:junit:4.12'

}

要先编译打包的时候不带有libs,很简单,删除compile fileTree(include: ['*.jar'],dir:'libs') 这行,把libs module需要引用的jar 文件用compile files 这种方式引入,修改后的dependencies 属性如下

dependencies {

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {

excludegroup:'com.android.support',module:'support-annotations'

})

compile'com.google.code.gson:gson:2.6.2'

testCompile'junit:junit:4.12'

compile files('libs/commons-lang-2.6.jar')

compile files('libs/simple-xml-2.7.jar')

compile files('libs/agnes_tracker-0.1.0.jar')

compile project(path:':okhttputills')

}

这样打包aar的时候将不一并打包libs目录

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容