错误是失败:生成失败,出现异常。
“* 出了什么问题:配置根项目“android”时出现问题。
未能解析配置“:classpath”的所有文件。无法找到com.android.tools.build:gradle:8.1.在以下位置搜索:- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.1/gradle-8.1.pom-https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/8.1/gradle-8.1.pom要求:项目:
- 试试看:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。运行--扫描以获得完整的见解。
- 在https://help.gradle.org获得更多帮助
BU�LD FAQURY in 2s Running Gradle task 'task leaderg'. 3、3s例外:Gradle任务验证失败,退出代码为% 1”
即使我修复了这个错误,我得到了不同的错误,无法编写任何代码。如果你有任何永久的解决方案,请发表评论。我的文件如下:(Gradle 8.1),(openjdk 17.0.6)
build.gradle/app
plugins{
apply plugin: 'com.android.application'
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "com.example.food"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.food"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:32.3.1')
implementation('com.google.firebase:firebase-analytics')
}
build.gradle
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
我试着更新和降级gradle,但仍然没有工作。
1条答案
按热度按时间xghobddn1#
我遇到了同样的问题,我设法通过更改
compileSdkVersion
,minSdkVersion
和targetSdkVersion
来修复它。app/build.gradle
我不确定它是否能修复你的问题,因为我使用的是
classpath 'com.android.tools.build:gradle:7.3.0'
,可能会尝试降级,或者对于8.1.x尝试引用here和here