最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

flutter - Execution failed for task ':gradle:compileKotlin' Cannot resolve external dependency com.android.tools

programmeradmin4浏览0评论

After upgrading from Flutter 3.27.1 to 3.29.0, I can no longer run flutter apps on my computer. Even creating a new project:

-> mkdir flutt
-> cd flut
-> flutter create . --platforms=android
-> flutter run
FAILURE: Build failed with an exception.



* What went wrong:
Execution failed for task ':gradle:compileKotlin'.
> Could not resolve all files for configuration ':gradle:compileClasspath'.
   > Cannot resolve external dependency com.android.tools.build:gradle:8.7.3 because no repositories are defined.
     Required by:
         project :gradle
   > Cannot resolve external dependency .jetbrains.kotlin:kotlin-stdlib:1.9.24 because no repositories are defined.
     Required by:
         project :gradle
   > Cannot resolve external dependency .jetbrains.kotlin:kotlin-reflect:1.9.24 because no repositories are defined.
     Required by:
         project :gradle

* 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 .

BUILD FAILED in 1s
Running Gradle task 'assembleDebug'...                           1,237ms
Error: Gradle task assembleDebug failed with exit code 1

Edit:

I'm using Android Studio Meerkat | 2024.3.1 Nightly 2025-01-12

Flutter doctor:

[✓] Flutter (Channel stable, 3.29.0, on Manjaro Linux 6.1.119-1-MANJARO, locale en_US.UTF-8) [217ms]
    • Flutter version 3.29.0 on channel stable at /home/bradleyk/snap/flutter/common/flutter
    • Upstream repository .git
    • Framework revision 35c388afb5 (5 days ago), 2025-02-10 12:48:41 -0800
    • Engine revision f73bfc4522
    • Dart version 3.7.0
    • DevTools version 2.42.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.1s]
    • Android SDK at /home/bradleyk/Android/Sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /home/bradleyk/.local/share/JetBrains/Toolbox/apps/android-studio/jbr/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12771278-b631.28)
    • All Android licenses accepted.

After upgrading from Flutter 3.27.1 to 3.29.0, I can no longer run flutter apps on my computer. Even creating a new project:

-> mkdir flutt
-> cd flut
-> flutter create . --platforms=android
-> flutter run
FAILURE: Build failed with an exception.



* What went wrong:
Execution failed for task ':gradle:compileKotlin'.
> Could not resolve all files for configuration ':gradle:compileClasspath'.
   > Cannot resolve external dependency com.android.tools.build:gradle:8.7.3 because no repositories are defined.
     Required by:
         project :gradle
   > Cannot resolve external dependency .jetbrains.kotlin:kotlin-stdlib:1.9.24 because no repositories are defined.
     Required by:
         project :gradle
   > Cannot resolve external dependency .jetbrains.kotlin:kotlin-reflect:1.9.24 because no repositories are defined.
     Required by:
         project :gradle

* 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..

BUILD FAILED in 1s
Running Gradle task 'assembleDebug'...                           1,237ms
Error: Gradle task assembleDebug failed with exit code 1

Edit:

I'm using Android Studio Meerkat | 2024.3.1 Nightly 2025-01-12

Flutter doctor:

[✓] Flutter (Channel stable, 3.29.0, on Manjaro Linux 6.1.119-1-MANJARO, locale en_US.UTF-8) [217ms]
    • Flutter version 3.29.0 on channel stable at /home/bradleyk/snap/flutter/common/flutter
    • Upstream repository https://github/flutter/flutter.git
    • Framework revision 35c388afb5 (5 days ago), 2025-02-10 12:48:41 -0800
    • Engine revision f73bfc4522
    • Dart version 3.7.0
    • DevTools version 2.42.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.1s]
    • Android SDK at /home/bradleyk/Android/Sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /home/bradleyk/.local/share/JetBrains/Toolbox/apps/android-studio/jbr/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12771278-b631.28)
    • All Android licenses accepted.
Share Improve this question edited Feb 15 at 15:55 King Bee asked Feb 15 at 12:35 King BeeKing Bee 813 silver badges15 bronze badges 4
  • Please edit the question to provide your build files so we can try to reproduce the issue. – tyg Commented Feb 15 at 12:44
  • What is your Android Studio version (if you are using that)? Also, can you post the output of running flutter doctor? – tomerpacific Commented Feb 15 at 13:43
  • @tyg I'm trying to add build files, but it says " It looks like your post is mostly code; please add some more details." However, I have created an issue with more details here. – King Bee Commented Feb 15 at 15:51
  • @tomerpacific Android Stuido version is Android Studio Meerkat | 2024.3.1 Nightly 2025-01-12. I can't add more code to the original code, but I created an issue in the flutter repo. Honestly, I think it might be an issue with my setup, but Idk where to begin – King Bee Commented Feb 15 at 15:52
Add a comment  | 

1 Answer 1

Reset to default 0

I edited ~/snap/flutter/common/flutter/packages/flutter_tools/gradle/build.gradle.kts

to add

repositories {
    google()
    mavenCentral()
}

and it now works.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论