Cannot find a version of '...' that satisfies the version constraints: 오류 해결
[문제정의]
debug모듈을 dependency 추가 후 에뮬레이터 실행은 잘되었지만
unittest를 실행했는데 다음과 같은 에러가 발생
Cannot find a version of 'com.google.code.findbugs:jsr305' that satisfies the version constraints:
Dependency path 'std of android with kt mvvm aac mock:app:unspecified' --> 'com.facebook.stetho:stetho:1.5.1' --> 'com.google.code.findbugs:jsr305:2.0.1'
Constraint path 'std of android with kt mvvm aac mock:app:unspecified' --> 'com.google.code.findbugs:jsr305:{strictly 2.0.1}' because of the following reason: debugRuntimeClasspath uses version 2.0.1
Dependency path 'std of android with kt mvvm aac mock:app:unspecified' --> 'com.facebook.stetho:stetho-okhttp3:1.5.1' --> 'com.google.code.findbugs:jsr305:2.0.1'
Dependency path 'std of android with kt mvvm aac mock:app:unspecified' --> 'androidx.test.ext:truth:1.2.0' --> 'com.google.guava:guava:26.0-android' --> 'com.google.code.findbugs:jsr305:3.0.2'
두 라이브러리가 같은 라이브러리지만 다른 버전의 dependency 의존시 높은 버전을 따름
두 라이브러리가 다른 build variable일 경우 충돌이 발생할 수 있음
다음 의존성이 충돌발생
모듈 1 :
implementation 'com.facebook.stetho:stetho:1.5.1'
implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1'
모듈 2 :
androidTestImplementation 'androidx.test.ext:truth:1.2.0'
[해결방안]
1. 중복된 의존성 중 하나 제거
2. 누락된 버전의 의존성 추가
implementation 'com.google.code.findbugs:jsr305:3.0.2'
3. gradle에 다음을 추가
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.2'
}
}
4. 의존성 exclude (?)
androidTestImplementation ("androidx.test.ext:truth:1.2.0") {
exclude 'com.facebook.stetho:stetho:1.5.1'
exclude 'com.facebook.stetho:stetho-okhttp3:1.5.1'
}
[ref]
https://github.com/invertase/react-native-firebase/issues/1954
https://stackoverflow.com/questions/55502447/cannot-find-a-version-of-com-google-code-findbugsjsr305