gpt4 book ai didi

android - 错误 :(28, 13) 无法解析 : com. squareup.okhttp3 :okhttp:3. 2.0

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:07:45 25 4
gpt4 key购买 nike

我有一个关于 android studio 的问题。

我已经从这个链接添加了 okhttp 的 .jar 文件: https://github.com/square/okhttp 到我的 android studio 上的 libs 目录。当我尝试添加这一行时:在 build.gradle(Module:app) 的依赖项中编译 'com.squareup.okhttp3:okhttp:3.2.0',在尝试同步它之后我得到错误 28、13。实际上之后研究我发现我无法编译依赖项中的任何内容并同步它记住我已经检查了我的“android SDK构建工具”已安装。

听到的是我在 build.gradle(app) 目录中的全部代码:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.example.kasra.stormy"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'], )
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile files('libs/okhttp-3.2.0.jar')
compile 'com.squareup.okhttp3:okhttp:3.2.0'
}

如果有人帮助我解决这个问题,我将非常高兴和感激。

非常感谢:)

最佳答案

要么您的互联网状况不佳,您无法从 JCenter 下载该文件,要么您的 gradle 文件中缺少一个 repositories 部分。

apply plugin: 'com.android.application'

repositories {
jcenter()
}

此外,如果您要使用 gradle 而不是 JAR 文件进行编译,请删除文件 libs/okhttp-3.2.0.jar 并删除显示 compile 的行文件('libs/okhttp-3.2.0.jar')

还值得一提的是,您不需要以 compile files('libs/> 开头的任何行,因为 compile fileTree(dir: 'libs', include: ['* .jar'], ) 已经在 libs/ 文件夹中包含所有 JAR 文件。

关于android - 错误 :(28, 13) 无法解析 : com. squareup.okhttp3 :okhttp:3. 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36269340/

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