No cached version of com.android.tools.build:gradle 3.6.1 available for offline mode解决方法

在Mac上的解决方法,按照以下步骤操作:

第一, 在项目的build.gradle中添加 classpath 'com.android.tools.build:gradle:3.6.1'

第二, 在gradle-wrapper.properties中,添加distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip ,注意使用5.x.x的版本不行。

第三,在AS底部Terminal按顺序执行两个命令:./gradlew clean./gradlew assemble

第四,如果控制台出现:Permission denied,则执行chmod +x gradlew

第五,命令完成后,重启AS,或点击sync now同步gradle配置。

最后,这个问题如此普遍,为什么AS不能提供检测并一键修复功能,给出的都是什么莫名提示,Offline work选项还在新版本里找不到了,浪费用户时间。

你可能感兴趣的:(Android)