flutter: getting gradle error while running my flutter app for the first time

谁说胖子不能爱 提交于 2021-01-29 13:30:55

问题


this is my first flutter app. Each time I just get error while running it.

I first thought it was a problem of connection even though my connection is good, I am still getting this nasty error

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.

回答1:


Try this,

in yourapp\android\build.gradle mavenCentral() in repositories and change gradle version 3.2.0 in dependencies

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

finally go to yourapp\android\gradle\wrapper\gradle-wrapper.properties and change gradle version 4.6,

distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip



回答2:


You need to be connected to the internet when building your application unless when creating the app, using android studio wizard you selected the offline option.



来源:https://stackoverflow.com/questions/58939423/flutter-getting-gradle-error-while-running-my-flutter-app-for-the-first-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!