我在 Android Studio 上尝试构建 flutter 应用程序时收到以下错误
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.otaliastudios:transcoder:0.9.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/otaliastudios/transcoder/0.9.1/transcoder-0.9.1.pom
- https://repo.maven.apache.org/maven2/com/otaliastudios/transcoder/0.9.1/transcoder-0.9.1.pom
- https://storage.googleapis.com/download.flutter.io/com/otaliastudios/transcoder/0.9.1/transcoder-0.9.1.pom
Required by:
project :app > project :video_compress
我尝试了
flutter clean
flutter pub cache repair
并且还删除了pubspec.lock..问题仍然没有解决
这是
flutter doctor
的结果
[√] Flutter (Channel stable, 3.3.4, on Microsoft Windows [Version 10.0.22621.819], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.73.1)
[√] VS Code, 64-bit edition (version 1.64.1)
[√] Connected device (4 available)
[√] HTTP Host Availability
由于这个answer
,我能够通过在项目级别 build.gradle 中添加这一行来找到解决方案allprojects {
repositories {
google()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" } //Added this line
}
}
另一个对我有用的解决方案,但使用 jcenter() ,它显然已达到服务结束
allprojects {
repositories {
google()
jcenter() //instead of mavenCentral()
}
}
显然这是 gradle 服务器问题,但不确定这是否是最好的解决方案,但它对我有用。
就我而言,删除
pubspec.lock
然后运行 flutter pub get
再次生成文件解决了问题。