如何依赖多个aar-Gradle配置
发布时间:2020-12-14 01:36:48 所属栏目:百科 来源:网络整理
导读:在Android Studio创建的主module app 依赖aar文件。 build.gradle中配置: android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { minSdkVersion 23 targetSdkVersion 25 versionCode 1 versionName "1.0" } repositories { //这部分
在Android Studio创建的主module app 依赖aar文件。
build.gradle中配置:
android { compileSdkVersion 25 buildToolsVersion "25.0.2" defaultConfig { minSdkVersion 23 targetSdkVersion 25 versionCode 1 versionName "1.0" } repositories { //这部分是关键 flatDir { dirs "libs" } } } dependencies { compile(name: ‘xxx’,ext: ‘aar’) } 如果主module (app)依赖的module (core)中依赖了aar文件,配置就要注意了:
core中build.gradle和上面添加一样:
dependencies { compile(name: ‘yyy’,ext: ‘aar’) } repositories { flatDir { dirs ‘libs’ } } 这是因为主app中 flatDir指定的路径是libs,只会在app本身的libs中查找,所以为了找到 core中的yyy.aar,也要提供正确路径。
则需要修改 主appmodule下的build.gradle
repositories { flatDir { dirs 'libs','../core/libs' } } 这次编译即可成功。如果还有更多的module,一样的配置即可。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |