无法确定 androidx.appcompat:appcompat:1.0.2 的工件:没有可用于离线模式的缓存版本

Zia*_*Zia 3 android android-appcompat

Gradle 依赖项是:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.hendraanggrian.material:collapsingtoolbarlayout-subtitle:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Run Code Online (Sandbox Code Playgroud)

每次清理和重建后,Gradle 项目同步都失败。

Shu*_*kam 16

  • 要解决此问题,请关闭 Gradle 离线模式。
  • 只需转到(android studio 3.6 及更高版本)

    查看 -> 工具窗口 -> Gradle -> 切换离线模式图标

    单击此处查看切换离线模式图标


Fay*_*med 6

Gradle 处于离线模式,这意味着它不会去网络解决依赖关系。

Go to Preferences (File->Settings->Build, Execution, Deployment) -> Gradle and uncheck "Offline work".
Run Code Online (Sandbox Code Playgroud)


Sia*_*dos -1

转到设置,然后搜索 gradle。这里有2个状态:

  1. 你的 gradle 设置为离线工作(通过 checkbo

  2. 您的 gradle 路径设置不正确(如果之前没有问题)

如果一切正常,则在设置页面中搜索代理并检查它们。您还可以在此处检查您的连接情况。

这3种方法或许可以解决问题。