简体   繁体   English

Android Studio无法获取库

[英]Android Studio Can't Fetch Library

I have recently started getting this issue with Android Studio and it has been driving me up the wall. 最近,我开始使用Android Studio解决此问题,这一直困扰着我。 I keep getting the error "Failed to resolve: com.squareup.okio:okio:1.8.0". 我不断收到错误“无法解决:com.squareup.okio:okio:1.8.0”。 These are the dependencies I have: 这些是我的依赖项:

dependencies {

    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'

    compile files('libs/okio-1.8.0.jar')

    compile files('libs/retrofit-2.1.0 (1).jar')
   }

As you can see, I have the retrofit and gson libraries simply compile (I'm assuming this downloads them from the internet), I tried doing the same with Okio however it didn't resolve, so I have speicifcally downloaded the 1.8.0 Okio JAR however it still fails to resolve. 如您所见,我仅对Retrofit和gson库进行了编译(我假设这是从Internet下载的),我尝试对Okio进行同样的操作,但是它没有解决,因此我专门下载了1.8.0。 Okio JAR但是仍然无法解决。 Why could this be? 为什么会这样呢? Any answer would be greatly appreciated. 任何答案将不胜感激。 Thank you 谢谢

Don't put dependencies as a Gradle dependency: 不要将依赖项作为Gradle依赖项:

compile 'com.squareup.retrofit2:retrofit:2.1.0'

And as a .jar file in src/libs : 并且作为src/libs的.jar文件:

compile files('libs/retrofit-2.1.0 (1).jar')

at one time . 一次 Choose only one method. 仅选择一种方法。 I advise you to choose Gradle dependencies, because they are automatically fetched. 我建议您选择Gradle依赖项,因为它们会自动获取。

In you case, the dependencies section should look like: 在这种情况下, dependencies部分应如下所示:

dependencies {
    compile `com.google.code.gson:gson:2.7`
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM