【发布时间】:2022-12-14 22:48:38
【问题描述】:
我有以下设置:
- Android Studio 2021.3.1
- 等级:7.4
根级别 build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
google()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.github.spotbugs:spotbugs-gradle-plugin:4.7.1'
}
}
allprojects {
repositories {
mavenCentral()
google()
maven { url 'https://jitpack.io' }
}
}
模块级 build.gradle:
import com.github.spotbugs.snom.SpotBugsTask
buildscript {
repositories {
mavenCentral()
google()
maven { url 'https://jitpack.io' }
}
}
plugins {
id 'com.android.library'
id 'checkstyle'
id 'com.github.spotbugs'
}
repositories {
mavenCentral()
google()
maven { url 'https://jitpack.io' }
}
apply from: "publisher.gradle"
<...>
dependencies {
implementation platform('com.google.firebase:firebase-bom:31.0.0')
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.mikepenz:materialdrawer:6.1.2'
implementation 'com.github.AppIntro:AppIntro:6.2.0'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-database'
implementation 'com.github.sematext:sematext-logsene-android:3.2.0'
implementation 'com.github.mik3y:usb-serial-for-android:3.4.6'
}
在做的同时梯度同步在 Android Studio 中,我遇到了以下错误:
文本中的第一个错误:
:projectName:main: Could not resolve androidx.appcompat:appcompat:1.5.1.
Required by:
project :projectName
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
正如您在上面看到的,我已经声明了包含这些依赖项的存储库,并且我确信这些版本存在。
我已经尝试过:清除 gradle 缓存、清除 Android Studio 缓存并重新启动、切换到另一个网络、关闭我的防火墙——没有任何帮助。我看到 gradle 已经成功地解决了完整列表中的一些依赖项(例如,materialdrawer 和 firebase)。
前段时间一切正常 - 我已经 2-3 个月没有打开这个项目了,它之前一直在工作。现在不是了,我不明白为什么。有人可以帮我吗?
啊,顺便说一下,“gradle clean”,然后是“gradle build”,它使用相同的依赖关系,成功完成,真正组装构建,在同一台笔记本电脑上的相同 Android Studio 实例上,只有“gradle sync”是失败。这让我真的不清楚发生了什么。
【问题讨论】:
标签: android android-studio gradle