gpt4 book ai didi

android - 为什么不在我的自定义库中添加 support-v4 依赖项运行时

转载 作者:行者123 更新时间:2023-11-29 23:49:59 27 4
gpt4 key购买 nike

我要制作自定义库。制作aar后,在另一个导入,找不到支持依赖。

我的库 Gradle 是:

dependencies {
implementation fileTree(include: ['*.jar'], exclude: ['classes2.jar'], dir: 'libs')
compileOnly files('libs/classes2.jar')

implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:multidex:1.0.1'
}

最佳答案

问题是因为您正在使用实现:

When your module configures an implementation dependency, it's letting Gradle know that the module does not want to leak the dependency to other modules at compile time. That is, the dependency is available to other modules only at runtime.

依赖自定义库的模块将看不到支持库。所以,你需要使用api:

When a module includes an api dependency, it's letting Gradle know that the module wants to transitively export that dependency to other modules, so that it's available to them at both runtime and compile time. This configuration behaves just like compile (which is now deprecated), and you should typically use this only in library modules.

将依赖 block 更改为如下内容:

dependencies {
implementation fileTree(include: ['*.jar'], exclude: ['classes2.jar'], dir: 'libs')
compileOnly files('libs/classes2.jar')

api 'com.android.support:support-v4:27.1.1'
api 'com.android.support:multidex:1.0.1'
}

关于android - 为什么不在我的自定义库中添加 support-v4 依赖项运行时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50961227/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com