侧边栏壁纸
博主头像
Stars-One的杂货小窝博主等级

所有的创作都是有价值的

  • 累计撰写 257 篇文章
  • 累计创建 46 个标签
  • 累计收到 27 条评论

目 录CONTENT

文章目录

Android 多module情况下module依赖aar问题处理

Stars-one
2022-11-15 / 0 评论 / 0 点赞 / 677 阅读 / 2844 字

原文: 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')

参考

0

评论区