解析失败:okhttp loggin-interceptor

Failed to resolve: okhttp loggin-interceptor

我正在使用 Retrofit 2.0.0-beta2 库与 API 进行通信。直到上周五,一切正常。今天我收到这个错误:

Failed to resolve: com.squareup.okhttp:logging-interceptor:2.6.0-SNAPSHOT

而且我无法摆脱它。我在网上搜索了一下,好像我的gradle个文件没问题:

build.gradle(项目)

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url 'http://oss.sonatype.org/content/repositories/snapshots' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(应用程序)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.package.app"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        //(...)
    }
}

dependencies {
    //(...)
    compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
    compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.squareup.okhttp:logging-interceptor:2.6.0-SNAPSHOT'
}

当我从依赖项中删除 `compile 'com.squareup.okhttp:logging-interceptor:2.6.0-SNAPSHOT' 时(这意味着我看不到 Retrofit 日志,但我确实想看到它们)一切正常。有人知道怎么解决吗?

今天 logging-interceptor 已更新至 2.6.0,您可以在 jCenter

上看到

将您的 build.gradle 从

更改为
dependencies {
    ...
    compile 'com.squareup.okhttp:logging-interceptor:2.6.0-SNAPSHOT'
}

至:

dependencies {
    ...
    compile 'com.squareup.okhttp:logging-interceptor:2.6.0'
}

2.6.0 版本已发布,因此您不再需要 -SNAPSHOT 后缀。如果您想继续使用快照版本,请改用 2.7.0-SNAPSHOT

证明:https://github.com/square/okhttp/issues/2027