方法一:
org.gradle.java.home=C:/Program Files/Java/jdk-17
方法二:
【问题描述】新建Android Kotlin应用,未修改,编译直接报错
【错误信息】 Could not resolve com.android.tools.build:gradle:8.0.0
【解决方案】Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
【解决措施】Settings->Build,Execution,Deployment->Build Tools->Gradle,修改Gradle JDK大于11版本,修改完成后,Sync Project
镜像:
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/public/'} //这行是我新加的使用阿里云
google()
mavenCentral()
// jcenter() // keeped as anchor, will be removed soon
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
下面说明来自,[阿里云](https://developer.aliyun.com/mvn/guide?spm=a2c4g.102512.0.0.62d92563hvenqT)
| 仓库名称 | 阿里云仓库地址 | 阿里云仓库地址(老版) | 源地址 |
|---|---|---|---|
| central | maven.aliyun.com/repository/… | maven.aliyun.com/nexus/conte… | repo1.maven.org/maven2/ |
| public | maven.aliyun.com/repository/… | maven.aliyun.com/nexus/conte… | central仓和jcenter仓的聚合仓 |
| gradle-plugin | maven.aliyun.com/repository/… | maven.aliyun.com/nexus/conte… | plugins.gradle.org/m2/ |
| apache snapshots | maven.aliyun.com/repository/… | maven.aliyun.com/nexus/conte… | repository.apache.org/snapshots/ |
gradle 配置指南
在 build.gradle 文件中加入以下代码:
allprojects {
repositories {
maven {
url 'https://maven.aliyun.com/repository/public/'
}
mavenLocal()
mavenCentral()
}
}
如果想使用其它代理仓,以使用 central 仓为例,代码如下:
allprojects {
repositories {
maven {
url 'https://maven.aliyun.com/repository/public/'
}
maven {
url 'https://maven.aliyun.com/repository/central'
}
mavenLocal()
mavenCentral()
}
}