使用实现而不是编译时无法访问库模块依赖项

问题描述 投票:1回答:1

使用compile关键字在gradle中添加依赖项时,我能够访问库模块的所有依赖项。

但是在使用implementation关键字时,我无法访问app模块中的那些依赖项,可在库模块gradle文件中找到。

我的框架依赖

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar']) 
    implementation 'com.android.support:appcompat-v7:27.1.1' 
    implementation 'com.android.support:support-v4:27.1.1' 
    implementation 'com.android.support:design:27.1.1' 
    implementation 'com.squareup.retrofit2:retrofit:2.3.0' 
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0' 
    implementation 'com.squareup.okhttp3:okhttp:3.10.0' 
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0' 
    implementation 'com.google.code.gson:gson:2.8.2' 
    implementation 'io.reactivex.rxjava2:rxjava:2.1.1' 
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1' 
    implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0' 
    implementation 'org.greenrobot:eventbus:3.1.1'
}

我的App依赖

dependencies {
implementation project(':framework')
implementation fileTree(include: ['*.jar'], dir: 'libs')
}

问题

如果我使用compile关键字来编译依赖项,它可以工作。如果我使用implementation关键字来编译依赖关系,它就不起作用

发出屏幕截图

enter image description here

java android android-gradle android-glide
1个回答
3
投票

使用api而不是实现。 api关键字将允许您在所有模块中使用依赖项

© www.soinside.com 2019 - 2024. All rights reserved.