1

My project was working fine before integrating Small case Library. After integration I'm getting this error at the time of installing application.

java.lang.NoSuchMethodError: No static method get(Ljava/lang/String;)Lokhttp3/HttpUrl; in class Lokhttp3/HttpUrl; or its super classes (declaration of 'okhttp3.HttpUrl' appears in /data/app/base.apk!classes3.dex)
        at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:506)

here I'm attaching App level gradle file.

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'


android {
    compileSdkVersion 29
    packagingOptions {
        exclude 'META-INF/*'
    }
    defaultConfig {
       
        minSdkVersion 23
        targetSdkVersion 29
       
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    configurations{
        all*.exclude module: 'okhttp'
        all*.exclude module: 'okio'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }




    buildToolsVersion '29.0.2'

}




dependencies {
    implementation project(path: ':library')
    implementation project(path: ':library')
    implementation project(path: ':library')
    testImplementation 'junit:junit:4.12'
 
    implementation 'com.smallcase.gateway:sdk:2.9.3'

    implementation ('com.squareup.retrofit2:retrofit:2.9.0') {
        exclude module: 'okhttp'
    }
    implementation 'com.google.code.gson:gson:2.6.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.okhttp3:okhttp:3.4.1'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
   

}

As mentioned in other answers I have already tried setting CompileOptions with Java 1.8. but no luck. Any help would be appreciated.

1
  • You are forcing an older version of okhttp which is breaking things. You should either be using 3.12.13 or 4.9.1. Commented Aug 15, 2021 at 6:44

1 Answer 1

1

use both the newest version (Retrofit & OkHttp)

https://github.com/square/retrofit/issues/3058

Sign up to request clarification or add additional context in comments.

2 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.