Muh*_*ris 2 dependencies android kotlin build.gradle retrofit
在我的新Kotlin项目中build.gradle为实现Retrofit API调用在文件中添加了以下依赖项。
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"
Run Code Online (Sandbox Code Playgroud)
同步后,它将显示下面提到的错误。
Could not get unknown property 'okhttpVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Run Code Online (Sandbox Code Playgroud)
工作室指向错误线是,
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
Run Code Online (Sandbox Code Playgroud)
请给出任何解决方案。
定义版本值,如
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"
Run Code Online (Sandbox Code Playgroud)
或尝试添加依赖项的硬编码版本
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"
Run Code Online (Sandbox Code Playgroud)
不要忘记清理和重建...
| 归档时间: |
|
| 查看次数: |
8926 次 |
| 最近记录: |