【问题标题】:Android build failed with Failed to resolve: com.squareup.retrofit2:convertor-gson:2.7.1Android 构建失败,无法解决:com.squareup.retrofit2:convertor-gson:2.7.1
【发布时间】:2021-03-02 21:49:59
【问题描述】:

我尝试为 com.squareup.retrofit2 模块构建.gradle 失败

    implementation "com.squareup.retrofit2:convertor-gson:${retrofitVersion}"
    implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"

带有错误信息:

Failed to resolve: com.squareup.retrofit2:convertor-gson:2.7.1

我的项目级 build.gradle 文件是:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        maven { url "https://jitpack.io" }
        jcenter()
        }


    dependencies {
        classpath "com.android.tools.build:gradle:4.1.2"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        maven { url "https://jitpack.io" }
        jcenter()
    }
}

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

应用级 build.gradle 文件为:


  compileSdkVersion 29
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.hedylamarr"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
Android Studio 4.1.2
Build #AI-201.8743.12.41.7042882, built on December 20, 2020
Runtime version: 1.8.0_242-release-1644-b3-6915495 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.16
GC: ParNew, ConcurrentMarkSweep
Memory: 1237M
Cores: 12
Registry: ide.new.welcome.screen.force=true, external.system.auto.import.disabled=true

【问题讨论】:

  • 试试 2.9.0 implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
  • 我试过了,还有几个..同样的错误..

标签: android android-studio build.gradle retrofit2


【解决方案1】:

以下内容适合我:

dependencies {
    ///////
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation("com.squareup.retrofit2:retrofit:2.9.0")
    implementation("com.squareup.okhttp3:okhttp:4.9.0") {
        force = true
    }

build.gradle

buildscript {
    ext.kotlin_version = '1.4.10'
    repositories {
        jcenter()
        mavenCentral()
        google()
        maven { url "https://jitpack.io" }
        maven { url "http://dl.bintray.com/vsmaks/maven" }
        maven { url "http://dl.bintray.com/dasar/maven" }
        maven() { url "https://oss.sonatype.org/content/repositories/snapshots" }
        maven {
            url "http://dl.bintray.com/piasy/maven"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        google()
        maven { url "https://jitpack.io" }
        maven { url "http://dl.bintray.com/vsmaks/maven" }
        maven { url "http://dl.bintray.com/dasar/maven" }
        maven() { url "https://oss.sonatype.org/content/repositories/snapshots" }
        maven {
            url "http://dl.bintray.com/piasy/maven"
        }
    }
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-22
    相关资源
    最近更新 更多