android - flutter :第一次运行我的 flutter 应用程序时出现gradle错误

标签 android gradle flutter dependencies

这是我的第一个Flutter应用。每次我在运行时遇到错误。

我首先以为这是连接问题,尽管我的连接很好,但仍然收到此讨厌的错误

Launching lib/main.dart on TECNO L8 Lite in debug mode...
Initializing gradle...
[{"event":"app.progress","params":{"appId":"e76fdc75-00d2-4f4c-bf6c-b272d9d82041","id":"1","progressId":null,"message":"Resolving dependencies..."}}]Resolving dependencies...

Error running Gradle:
ProcessException: Process "/home/gun/projet/non_academic/perso/flutter_app_test/android/gradlew" exited abnormally:
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
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:3.2.1.
 Required by:
     project :
  > Could not resolve com.android.tools.build:gradle:3.2.1.
     > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
        > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
           > Connect to localhost:80 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
  > Could not resolve com.android.tools.build:gradle:3.2.1.
     > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
        > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
           > Connect to localhost:80 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
    Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71.
 Required by:
     project :
    Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71.
     > Could not get resource 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.71/kotlin-gradle-plugin-1.2.71.pom'.
        > Could not GET 'https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.71/kotlin-gradle-plugin-1.2.71.pom'.
           > Connect to localhost:80 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
     Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.71.
     Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.71/kotlin-gradle-plugin-1.2.71.pom'.
        > Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.71/kotlin-gradle-plugin-1.2.71.pom'.
           > Connect to localhost:80 [localhost/127.0.0.1] failed: Connection refused (Connection refused)

 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.


BUILD FAILED in 28s
Command: /home/gun/projet/non_academic/perso/flutter_app_test/android/gradlew app:properties

 Finished with error: Please review your Gradle project setup in the android/ folder.

最佳答案

试试这个,

yourapp \ android \ build.gradle仓库中的 mavenCentral()并在依赖项中更改gradle版本3.2.0

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
    }
}

最后转到 yourapp \ android \ gradle \ wrapper \ gradle-wrapper.properties 并更改gradle版本4.6,
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

关于android - flutter :第一次运行我的 flutter 应用程序时出现gradle错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58939423/

相关文章:

php - PHP 的 gmmktime() 在 Dart/Flutter 中的等价物是什么?

android - Admob 原生广告中的可点击区域

android - 使用导航模式隐藏 actionBar 选项卡会对 fragment 后台堆栈产生不利影响

android - 设置Android中ListView的 'empty'区域的颜色

gradle - Gradle init无法创建项目

android - 未指定 buildToolsVersion,所有 "apply plugin: xxxx "在 app/build.gradle

flutter - 使用指纹而不是密码登录应用程序

android - 是否可以通过 NFC 一键连接两个 Android 设备交换数据?

android - 获取简单列表项单选 - 获取所选项目

android - 为 APK 和 app bundle 使用单独的签名 key