gpt4 book ai didi

android - 无法为类型为 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 的对象获取未知属性 'okhttpVersion'

转载 作者:行者123 更新时间:2023-12-02 13:09:22 25 4
gpt4 key购买 nike

build.gradle 文件中添加了以下依赖项,用于在我的新 Kotlin 项目中实现 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"

同步后会显示下面提到的错误。

Could not get unknown property 'okhttpVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

工作室指向错误线是,

implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"

请给出任何解决方案。

最佳答案

像这样定义版本值

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"

尝试添加依赖的硬编码版本

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"

不要忘记清理和重建...

关于android - 无法为类型为 org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler 的对象获取未知属性 'okhttpVersion',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49788747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com