简记一个Flutter错误:
Using hardware rendering with device sdk gphone64 x86 64. If you notice graphics artifacts, consider enabling software
rendering with “–enable-software-rendering”.
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode…
WARNING: [Processor] Library ‘C:\Users\jcstudio.gradle\caches\modules-2\files-2.1\androidx.media2\media2-session\1.2.1\f927563711e36371c19b2e86fb7ccf1c3f259ca4\media2-session-1.2.1.aar’ contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: ‘androidx/media2/session/MediaBrowserB u i l d e r ′ E x a m p l e o f s u p p o r t l i b r a r y r e f e r e n c e : ′ a n d r o i d / s u p p o r t / v 4 / m e d i a / s e s s i o n / M e d i a S e s s i o n C o m p a t Builder' Example of support library reference: 'android/support/v4/media/session/MediaSessionCompatBuilder′Exampleofsupportlibraryreference:′android/support/v4/media/session/MediaSessionCompatToken’
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ‘:fluttertoast:compileDebugKotlin’.
Error while evaluating property ‘filteredArgumentsMap’ of task ‘:fluttertoast:compileDebugKotlin’
Could not resolve all files for configuration ‘:fluttertoast:debugCompileClasspath’.
Failed to transform kotlin-stdlib-1.7.0.jar (org.jetbrains.kotlin:kotlin-stdlib:1.7.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
Could not download kotlin-stdlib-1.7.0.jar (org.jetbrains.kotlin:kotlin-stdlib:1.7.0)
Could not get resource ‘https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.7.0/kotlin-stdlib-1.7.0.jar’.
Could not GET ‘https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.7.0/kotlin-stdlib-1.7.0.jar’.
Read timed out
Failed to transform kotlin-stdlib-common-1.7.0.jar (org.jetbrains.kotlin:kotlin-stdlib-common:1.7.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
Could not download kotlin-stdlib-common-1.7.0.jar (org.jetbrains.kotlin:kotlin-stdlib-common:1.7.0)
Could not get resource ‘https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.7.0/kotlin-stdlib-common-1.7.0.jar’.
Could not GET ‘https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.7.0/kotlin-stdlib-common-1.7.0.jar’.
Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: Read timed out
- 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 2m 14s
Running Gradle task ‘assembleDebug’… 134.8s
[!] Gradle threw an error while downloading artifacts from the network.
Retrying Gradle Build: #1, wait time: 100ms
FAILURE: Build failed with an exception.
- What went wrong:
Execution failed for task ‘:audio_session:compileDebugJavaWithJavac’.
Could not resolve all files for configuration ‘:audio_session:debugCompileClasspath’.
Failed to transform listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
Could not download listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)
Could not get resource ‘https://repo.maven.apache.org/maven2/com/google/guava/listenablefuture/1.0/listenablefuture-1.0.jar’.
Could not GET ‘https://repo.maven.apache.org/maven2/com/google/guava/listenablefuture/1.0/listenablefuture-1.0.jar’.
Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: Connection timed out: no further information
- 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 1m 10s
Running Gradle task ‘assembleDebug’… 70.8s
[!] Gradle threw an error while downloading artifacts from the network.
Exception: Gradle task assembleDebug failed with exit code 1
这个错误主要问题是Gradle在构建应用程序时无法下载所需的依赖项。这可能是由于网络问题或依赖项的版本不一致引起的。可以尝试以下几种方法来解决此问题:
检查网络连接: 首先,请确保电脑具有稳定的国际互联网连接。如果使用代理,请确保Gradle可以访问所需的依赖项。
使用案例镜像源: 如果不能科学上网,可以尝试使用国内的镜像源,以加速依赖项下载。在项目根目录下的 build.gradle
文件中,可以添加类似以下内容的镜像配置:
buildscript { repositories { maven { url 'https://maven.aliyun.com/repository/jcenter' } } } allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/jcenter' } } }
然后重新运行 flutter run
命令。
清除Gradle缓存: 有时Gradle缓存中的文件可能会损坏。可以尝试清除Gradle缓存,然后重新构建项目。在项目根目录中运行以下命令:
flutter clean
然后再运行 flutter run
。
OK