以前这个项目一直可以编译放了几个月,我换了一个windows帐号登录,结果编译不了
之前使用的是gradle-7.2.0,现在由于这几天开会,可能网络不畅通更新不了插件。
原因一,Google仓库连不上
build.gradle注释掉google()和jcenter()用阿里源替换
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
//google()
//jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0'
//classpath 'com.android.tools.build:gradle:3.5.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
ext {
// The following are only a few examples of the types of properties you can define.
compileSdkVersion = 29
// You can also create properties to specify versions for dependencies.
// Having consistent versions between modules can avoid conflicts with behavior.
supportLibVersion = "28.0.0"
minSdkVersion = 21
targetSdkVersion = 22
}
}
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
//google()
//jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
另外现在支持的最低的gradle版本为7.5插件版本为7.4,也要同步更新一下
gradle-wrapper.properties
#Wed Apr 08 11:23:28 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
配置好后再点一下大象按钮
就可以正常运行调试了。 如果别的工程想复用gradle,可以改下这个目录