Following dependencies are added inside build.gradle
file for Implementing Retrofit API Call in My new Kotlin Project.
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
implementation ("com.squareup.retrofit2:retrofit:$retrofitVersion"){
exclude module: 'okhttp'
}
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
After Syncing it will show an error mentioned below.
Could not get unknown property 'okhttpVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
studio pointing error line is,
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
please give any Solution for it.
Define version value like
def okhttpVersion = "3.10.0"
def retrofitVersion = "2.4.0"
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
implementation ("com.squareup.retrofit2:retrofit:$retrofitVersion"){
exclude module: 'okhttp'
}
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
OR try to add hardcoded version of dependencies
implementation "com.squareup.okhttp3:okhttp:3.10.0"
implementation "com.squareup.okhttp3:logging-interceptor:3.10.0"
implementation ("com.squareup.retrofit2:retrofit:2.4.0"){
exclude module: 'okhttp'
}
implementation "com.squareup.retrofit2:converter-gson:2.4.0"
don't forget to clean and rebuild...