使用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
关键字来编译依赖关系,它就不起作用
发出屏幕截图
使用api而不是实现。 api关键字将允许您在所有模块中使用依赖项