1:问题描述
在module中依赖aar后,运行会报app找不到module所依赖的aar包,如:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not find :alipaysdk-15.8.03.210428205839:.
Required by:
project :app > project :lib_share
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
2:问题修复方案:
方案一:
在所有需要依赖此module的build.gradle 文件中添加此配置:
repositories {
flatDir {
dirs '../lib_share/libs'
}
}
若是module很多的话,此方法需要在每个module中配置下
方案二:
在项目根目录中的build.gradle中添加此配置:
allprojects {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}
mavenCentral()
google()
jcenter()
// flatDir {
// dirs project(':lib_share').file("libs")
// }
}
}
省了很多事
网友评论