You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio中Gradle依赖解析失败求助:com.szagurskii等依赖问题

解决Gradle依赖解析失败:patternedtextwatcher与Retrofit Gson转换器问题

我看到你遇到了两个Gradle依赖相关的问题,咱们一个个来解决:

1. 先修复Retrofit Gson转换器的拼写错误

你写的依赖implementation 'com.squareup.retrofit2:converted-gson:2.3.0'里有个明显的拼写错误——converted应该是converter,这是导致解析失败的直接原因之一。把它改成:

implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

2. 解决com.szagurskii:patternedtextwatcher:0.5.0的依赖解析失败

这个问题大概率是因为项目没有配置包含该库的仓库。这个库托管在JCenter上,你需要确保项目根目录的build.gradle文件中已经添加了JCenter仓库(JCenter虽已归档,但仍可访问旧版本库)。

打开根目录的build.gradle,检查allprojects下的repositories块,确保包含以下内容:

allprojects {
    repositories {
        google()
        jcenter() // 这是获取patternedtextwatcher的关键仓库
        maven { url "https://jitpack.io" } // 你用到的spots-dialog需要这个,已有则无需修改
    }
}

修改后的完整dependencies块

这里是修正后的依赖代码,你可以直接替换原内容:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.rengwuxian.materialedittext:library:2.1.4'
    implementation 'com.szagurskii:patternedtextwatcher:0.5.0'
    implementation 'com.github.d-max:spots-dialog:0.7@aar'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0' // 已修正拼写错误
}

做完这些修改后,点击Android Studio工具栏的Sync Project with Gradle Files按钮重新同步项目,应该就能解决这两个依赖解析问题了。

内容的提问来源于stack exchange,提问作者Nurudin Mohd Shah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:46:15