Android 多module情况下module依赖aar问题处理
2023-02-18 16:38:37 时间
原文: Android 多module情况下module依赖aar问题处理 - Stars-One的杂货小窝
问题描述
负责一个大项目Android工程项目,新增了一个module,而此module由于sdk的关系,需要引入SDK的aar文件
在Module的build.gradle文件里引入:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(name: 'ocrsdk', ext: '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
解决方法
方法1
在所有需要依赖此module的build.gradle 文件中添加此配置:
repositories {
flatDir {
dirs '../lib_share/libs'
}
}
比如,我是在app的module去引用了我的这个Module,应该在app里的build.gradle文件中写上上述代码,如下图所示:
方法2
如果有很多模块都依赖了这个模块,可以在全局的build.gradle(根目录)配置
repositories {
flatDir {
dirs project(":ocr").file("libs")
}
}
方法3
更改一下依赖方式,如下所示:
implementation files('libs/ocrsdk.aar')
参考
相关文章
- 移动研发提效?小程序容器技术来帮忙!
- 微信小程序(一)自定义导航栏和fixed失效及各机型兼容问题
- 微信小程序(二)学妹问我微信小程序左滑删除怎么实现
- 微信小程序(三)实现类似Vue中的 computed,watch 功能
- 微信小程序(四)绝对不可错过切换自定义菜单栏的骚操作
- 一文说透小程序插件及其作用价值
- android learning
- 微信小程序HTTPS - cenos apache 下安装SSL证书
- 3小时!开发ChatGPT微信小程序
- iOS 裁包大作战 —— JOOX Music 如何瘦身40MB
- 只需4步!带你成功将小程序转为APP
- 设计师应该了解的iOS应用开发基础知识
- 小程序容器技术成为组装式应用基础
- 「Native+小程序」,App热更新技术最优解
- 混合式App开发背景下,「Native+小程序」成为最优解
- 不改一行代码,就可以将微信小程序转成商业App?
- 技术分享|如何运用FinClip轻松将微信小程序转成商业App
- R8在Android手Q中的应用
- vue axios ajax引擎
- bootstrap添加模态窗后,再弹出消息提示框后,原先的滚动条消失