Android: Could not resolve junit:junit:{strictly 4.12}

157 Views Asked by At

I am getting this error and I'm not able to fix it.

     Required by:
         project :app
      > Cannot find a version of 'junit:junit' that satisfies the version constraints: 
           Dependency path 'app1-android-new:app:unspecified' --> 'com.squareup.okhttp3:mockwebserver:4.8.1' --> 'junit:junit:4.13'
           Constraint path 'app1-android-new:app:unspecified' --> 'junit:junit:{strictly 4.12}' because of the following reason: app1ChinaDebugRuntimeClasspath uses version 4.12
           Dependency path 'app1-android-new:app:unspecified' --> 'com.squareup.spoon:spoon-client:2.0.0-SNAPSHOT' --> 'junit:junit:4.12'
           Dependency path 'app1-android-new:app:unspecified' --> 'com.madgag.spongycastle:prov:1.58.0.0' --> 'junit:junit:4.12'
           Dependency path 'app1-android-new:app:unspecified' --> 'androidx.test.ext:junit-ktx:1.1.2' --> 'androidx.test.ext:junit:1.1.2' --> 'junit:junit:4.12'
           Dependency path 'app1-android-new:app:unspecified' --> 'androidx.test:runner:1.3.0' --> 'junit:junit:4.12'

versions I'm using when I get this error:

    const val okhttpInterceptor = "3.12.0"
    const val okio = "2.9.0"
    const val retrofit = "2.6.0"
    const val retrofitRx2 = "2.6.0"

Seems like okhttp:mockwebserver is utilizing junit 4.13. and some of my other dependencies are using junit 4.12. I've tried downgrading okhttp to a version that's using something lower than 4.13 but then my app crashes and i get this error:

Caused by: java.lang.NoSuchMethodError: No virtual method log(ILjava/lang/String;Ljava/lang/Throwable;)V in class Lokhttp3/internal/platform/Platform; or its super classes (declaration of 'okhttp3.internal.platform.Platform' appears in /data/app/com.jorge.app1.debug-k_18njhQd27pvQG1QCGQRQ==/base.apk!classes6.dex)
        at okhttp3.logging.HttpLoggingInterceptor$Logger$1.log(HttpLoggingInterceptor.java:114)
        at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:173)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
        at com.jorge.app1.user.login.auth.App1OAuthInterceptor.intercept(App1OAuthInterceptor.kt:56)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
        at com.jorge.app1.core.dagger.modules.RestAdapterModule.lambda$newAcceptJsonInterceptor$1(RestAdapterModule.java:123)
        at com.jorge.app1.core.dagger.modules.-$$Lambda$RestAdapterModule$dOYxq_scRVS7w_Kdax6-P-YEa5g.intercept(Unknown Source:0)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
        at com.jorge.app1.core.dagger.modules.RestAdapterModule.lambda$newUncaughtRetrofitErrorExceptionInterceptor$0(RestAdapterModule.java:105)
        at com.jorge.app1.core.dagger.modules.-$$Lambda$RestAdapterModule$fzk7ISIzK5IQGID0PN4BpyDWg3k.intercept(Unknown Source:0)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:100)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:197)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:148)
        at com.newrelic.agent.android.instrumentation.okhttp3.CallExtension.execute(CallExtension.java:45)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:204)
        at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:46)
        at io.reactivex.Observable.subscribe(Observable.java:12284)
        at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
        at io.reactivex.Single.subscribe(Single.java:3666)
        at io.reactivex.internal.operators.single.SingleMap.subscribeActual(SingleMap.java:34)
        at io.reactivex.Single.subscribe(Single.java:3666)
        at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
        at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:608)

versions I'm using when I get this error:

 const val okHttp3 = "4.9.0"
    const val okhttpInterceptor = "4.9.0"
    const val okio = "2.9.0"
    const val retrofit = "2.9.0"
    const val retrofitRx2 = "2.9.0"

Note: I cant upgrade junit to 4.13 bc I get the same mismatch error since most of the other dependencies rely on junit 4.12

0

There are 0 best solutions below