簡體   English   中英

由於 Gradle 錯誤,Flutter 運行無法正常工作。 嘗試了所有解決方案,但沒有奏效。 gradle 的問題

[英]Flutter run not working due to Gradle error. Tried all the solutions but not working. Problem with gradle

當我運行flutter run --no-sound-null safety

這顯示了 output。 我已經嘗試了所有可用的解決方案。 但不工作。 這是錯誤

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:4.1.0.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:4.1.0.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'.
               > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 37s

我的 android/build.gradle 文件

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我的 android/gradle/wrapper/gradle-wrapper.properties 文件內容是:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

我不知道如何解決這個問題,請幫忙..我從 1 天開始就在嘗試。 一切正常,但突然出現這個錯誤..提前致謝。

檢查你是否有你的互聯網。 其次,在andriod build 中升級ext.kotlin_version。 gradle 到 1.5.31 或更高版本並嘗試再次運行應用程序

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM