颤振:第一次运行我的颤振应用程序时出现 gradle 错误
Posted
技术标签:
【中文标题】颤振:第一次运行我的颤振应用程序时出现 gradle 错误【英文标题】:flutter: getting gradle error while running my flutter app for the first time 【发布时间】:2020-03-15 06:57:45 【问题描述】:这是我的第一个颤振应用程序。每次运行时都会出错。
我一开始以为是连接问题,即使我的连接很好,我仍然收到这个讨厌的错误
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】:您在构建应用程序时需要连接到互联网,除非在创建应用程序时使用 android studio 向导选择了离线选项。
【讨论】:
【参考方案2】:试试这个,
在 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
【讨论】:
以上是关于颤振:第一次运行我的颤振应用程序时出现 gradle 错误的主要内容,如果未能解决你的问题,请参考以下文章
颤振运行时出现:app:processDebugResources的一些未知错误
每次在 vscode 中运行我的颤振应用程序时出现此错误 [重复]
构建 Gradle 时出现问题(无法创建任务 ':path_provider_android:generateDebugUnitTestConfig')。在颤振中为 android
构建 appbundle 时出现颤振错误(脚本'/Users/****/Developer/flutter/packages/flutter_tools/gradle/flutter.gradle'