1

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

但是在使用implementation关键字时,我无法访问应用程序模块中的那些依赖项,这些依赖项在库模块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'
}

我的应用依赖

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

问题

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

发出截图

在此处输入图像描述

4

1 回答 1

3

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

于 2018-05-12T06:21:54.343 回答