不要重复依赖
Do not duplicate dependencies
我有一个具有下一个依赖项的库:
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'
现在我需要使用这个库将相同的依赖项添加到我的主项目中。
我如何实现该库,以便所有这些依赖项不会在主项目中重复?
现在在我的项目中我写:
implementation 'com.mandarine.sdk:mandarine-library:2.0.1@aar'
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'//Don't update while support Android SDK < 20
在图书馆:
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'
更新:
接下来也尝试在我的项目中写:
api 'com.mandarine.sdk:mandarine-library:2.0.1@aar'
并像这样修改了我的库:
api 'com.google.android.gms:play-services-safetynet:17.0.0'
api 'com.squareup.retrofit2:retrofit:2.5.0'
api 'com.squareup.retrofit2:converter-gson:2.5.0'
api 'com.squareup.okhttp3:logging-interceptor:3.12.2'
不幸的是也不起作用。
从每个库中排除您不想包含的依赖项
implementation('com.your.library') {
exclude module: 'library1'
exclude module: 'library2'
}
下一个解决方案已解决的问题:
implementation ('com.saltedge.sdk:saltedge-library:2.0.2@aar') {
transitive = true
}
这有助于我在库中使用依赖项,并且不要在主项目中重复它们。
我有一个具有下一个依赖项的库:
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'
现在我需要使用这个库将相同的依赖项添加到我的主项目中。
我如何实现该库,以便所有这些依赖项不会在主项目中重复?
现在在我的项目中我写:
implementation 'com.mandarine.sdk:mandarine-library:2.0.1@aar'
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'//Don't update while support Android SDK < 20
在图书馆:
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.12.2'
更新: 接下来也尝试在我的项目中写:
api 'com.mandarine.sdk:mandarine-library:2.0.1@aar'
并像这样修改了我的库:
api 'com.google.android.gms:play-services-safetynet:17.0.0'
api 'com.squareup.retrofit2:retrofit:2.5.0'
api 'com.squareup.retrofit2:converter-gson:2.5.0'
api 'com.squareup.okhttp3:logging-interceptor:3.12.2'
不幸的是也不起作用。
从每个库中排除您不想包含的依赖项
implementation('com.your.library') {
exclude module: 'library1'
exclude module: 'library2'
}
下一个解决方案已解决的问题:
implementation ('com.saltedge.sdk:saltedge-library:2.0.2@aar') {
transitive = true
}
这有助于我在库中使用依赖项,并且不要在主项目中重复它们。