在寫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目錄
作者:tiger桂
鏈接:https://www.jianshu.com/p/85bc7d23b4cb
來源:簡書
著作權歸作者所有。商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。