admin管理员组文章数量:1025526
I have a basic Flutter project in Android Studio, but whenever I add any external package (example: google_fonts), the compilation fails with a Gradle error.
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':path_provider_android:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':path_provider_android:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, .gradle.libraryelements=jar, .gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: C:\Users\dimitri\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
> Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\dimitri\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\dimitri\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}
* 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 26s
Error: Gradle task assembleDebug failed with exit code 1
Here are the details about the installed versions:
Flutter/Dart Versions:
flutter --version
Flutter 3.24.5 • channel stable • .git
Framework • revision dec2ee5c1f (5 days ago) • 2024-11-13 11:13:06 -0800
Engine • revision a18df97ca5
Tools • Dart 3.5.4 • DevTools 2.37.3
Gradle/Java versions:
PS E:\DevEnv\flutter\projects\doit\lesson01\android> ./gradlew -version
------------------------------------------------------------
Gradle 8.3
------------------------------------------------------------
Build time: 2023-08-17 07:06:47 UTC
Revision: 8afbf24b469158b714b36e84c6f4d4976c86fcd5
Kotlin: 1.9.0
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 17.0.12 (Oracle Corporation 17.0.12+8-LTS-286)
OS: Windows 11 10.0 amd64
Pubspec.Yaml
name: lesson01
description: "DoIt Lesson Project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=3.5.0 <4.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.8
google_fonts: ^6.2.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter:
uses-material-design: true
Kindly advice where is the problem source and how can i fix it?
I have a basic Flutter project in Android Studio, but whenever I add any external package (example: google_fonts), the compilation fails with a Gradle error.
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':path_provider_android:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':path_provider_android:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, .gradle.libraryelements=jar, .gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: C:\Users\dimitri\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
> Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\dimitri\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\dimitri\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}
* 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 26s
Error: Gradle task assembleDebug failed with exit code 1
Here are the details about the installed versions:
Flutter/Dart Versions:
flutter --version
Flutter 3.24.5 • channel stable • https://github/flutter/flutter.git
Framework • revision dec2ee5c1f (5 days ago) • 2024-11-13 11:13:06 -0800
Engine • revision a18df97ca5
Tools • Dart 3.5.4 • DevTools 2.37.3
Gradle/Java versions:
PS E:\DevEnv\flutter\projects\doit\lesson01\android> ./gradlew -version
------------------------------------------------------------
Gradle 8.3
------------------------------------------------------------
Build time: 2023-08-17 07:06:47 UTC
Revision: 8afbf24b469158b714b36e84c6f4d4976c86fcd5
Kotlin: 1.9.0
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 17.0.12 (Oracle Corporation 17.0.12+8-LTS-286)
OS: Windows 11 10.0 amd64
Pubspec.Yaml
name: lesson01
description: "DoIt Lesson Project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=3.5.0 <4.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.8
google_fonts: ^6.2.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter:
uses-material-design: true
Kindly advice where is the problem source and how can i fix it?
Share Improve this question edited Nov 19, 2024 at 7:26 ussrback asked Nov 18, 2024 at 10:40 ussrbackussrback 6212 gold badges10 silver badges27 bronze badges 4 |1 Answer
Reset to default 1I can't reproduce the error in my side by simply adding the google_fonts
because I didn't encountered the exception after I add that plugin to my pubspec.yaml
(i.e., built successful).
So I've decided to represent to you my configurations.
Under the gradle-wrapper.properties
:
distributionUrl=https://services.gradle./distributions/gradle-8.10.2-bin.zip, or use the latest one, or if necessary, downgrade it. Here is the reference
TIPS:
I also do this way to update the distributionUrl,
PS: C:\to_your_project_directory> cd android
PS: C:\to_your_project_directory\android> .\gradlew clean
PS: C:\to_your_project_directory\android> ./gradlew wrapper --gradle-version version_here(x.x.x) --distribution-type all
or
PS: C:\to_your_project_directory\android> ./gradlew wrapper --gradle-version version_here(x.x.x)
or
PS: C:\to_your_project_directory\android> ./gradlew wrapper --gradle-version latest
Under the settings.gradle
:
id ".jetbrains.kotlin.android" version "2.0.21" apply false //if necessary, downgrade it. Here is the reference
Under the android\build.gradle
:
buildscript {
ext.kotlin_version = '2.0.21' //if necessary, downgrade it.
repositories {
google()
mavenCentral()
}
dependencies {
classpath ".jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Also, consider this compatibility matrix
Update:
Please use these approaches if necessary:
In your Android Studio, Go to File > Invalidate Caches
Then you can do some troubleshooting practices:
PS: C:\to_your_project_directory> flutter clean
PS: C:\to_your_project_directory> flutter pub get
PS: C:\to_your_project_directory> flutter pub cache repair
PS: C:\to_your_project_directory> cd android
PS: C:\to_your_project_directory\android> .\gradlew clean
Additionals:
PS: C:\to_your_project_directory\android> ./gradlew build --stacktrace --info
To see what plugins or packages introduces the issues
NOTE:
The goal is to make sure that after you configure build.gradle, gradle-wrapper.properties, etc. You also clean the caches, then rebuild them.
I hope it helps!
I have a basic Flutter project in Android Studio, but whenever I add any external package (example: google_fonts), the compilation fails with a Gradle error.
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':path_provider_android:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':path_provider_android:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, .gradle.libraryelements=jar, .gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: C:\Users\dimitri\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
> Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\dimitri\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\dimitri\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}
* 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 26s
Error: Gradle task assembleDebug failed with exit code 1
Here are the details about the installed versions:
Flutter/Dart Versions:
flutter --version
Flutter 3.24.5 • channel stable • .git
Framework • revision dec2ee5c1f (5 days ago) • 2024-11-13 11:13:06 -0800
Engine • revision a18df97ca5
Tools • Dart 3.5.4 • DevTools 2.37.3
Gradle/Java versions:
PS E:\DevEnv\flutter\projects\doit\lesson01\android> ./gradlew -version
------------------------------------------------------------
Gradle 8.3
------------------------------------------------------------
Build time: 2023-08-17 07:06:47 UTC
Revision: 8afbf24b469158b714b36e84c6f4d4976c86fcd5
Kotlin: 1.9.0
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 17.0.12 (Oracle Corporation 17.0.12+8-LTS-286)
OS: Windows 11 10.0 amd64
Pubspec.Yaml
name: lesson01
description: "DoIt Lesson Project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=3.5.0 <4.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.8
google_fonts: ^6.2.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter:
uses-material-design: true
Kindly advice where is the problem source and how can i fix it?
I have a basic Flutter project in Android Studio, but whenever I add any external package (example: google_fonts), the compilation fails with a Gradle error.
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':path_provider_android:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':path_provider_android:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, .gradle.libraryelements=jar, .gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: C:\Users\dimitri\AppData\Local\Android\sdk\platforms\android-34\core-for-system-modules.jar.
> Error while executing process C:\Program Files\Android\Android Studio\jbr\bin\jlink.exe with arguments {--module-path C:\Users\dimitri\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\temp\jmod --add-modules java.base --output C:\Users\dimitri\.gradle\caches\transforms-3\4a46fc89ed5f9adfe3afebf74eb8bfeb\transformed\output\jdkImage --disable-plugin system-modules}
* 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 26s
Error: Gradle task assembleDebug failed with exit code 1
Here are the details about the installed versions:
Flutter/Dart Versions:
flutter --version
Flutter 3.24.5 • channel stable • https://github/flutter/flutter.git
Framework • revision dec2ee5c1f (5 days ago) • 2024-11-13 11:13:06 -0800
Engine • revision a18df97ca5
Tools • Dart 3.5.4 • DevTools 2.37.3
Gradle/Java versions:
PS E:\DevEnv\flutter\projects\doit\lesson01\android> ./gradlew -version
------------------------------------------------------------
Gradle 8.3
------------------------------------------------------------
Build time: 2023-08-17 07:06:47 UTC
Revision: 8afbf24b469158b714b36e84c6f4d4976c86fcd5
Kotlin: 1.9.0
Groovy: 3.0.17
Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM: 17.0.12 (Oracle Corporation 17.0.12+8-LTS-286)
OS: Windows 11 10.0 amd64
Pubspec.Yaml
name: lesson01
description: "DoIt Lesson Project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=3.5.0 <4.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.8
google_fonts: ^6.2.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
flutter:
uses-material-design: true
Kindly advice where is the problem source and how can i fix it?
Share Improve this question edited Nov 19, 2024 at 7:26 ussrback asked Nov 18, 2024 at 10:40 ussrbackussrback 6212 gold badges10 silver badges27 bronze badges 4-
Have you executed
flutter pub get
after adding the dependency? – Tim Hansen Commented Nov 18, 2024 at 10:53 - Yes sure, and "flutter pub autdated" after it – ussrback Commented Nov 18, 2024 at 11:50
- Can you show us your file pubspec.yaml? – Alexandre B. Commented Nov 19, 2024 at 1:13
- I have added Pubspec.yaml for your review – ussrback Commented Nov 19, 2024 at 7:27
1 Answer
Reset to default 1I can't reproduce the error in my side by simply adding the google_fonts
because I didn't encountered the exception after I add that plugin to my pubspec.yaml
(i.e., built successful).
So I've decided to represent to you my configurations.
Under the gradle-wrapper.properties
:
distributionUrl=https://services.gradle./distributions/gradle-8.10.2-bin.zip, or use the latest one, or if necessary, downgrade it. Here is the reference
TIPS:
I also do this way to update the distributionUrl,
PS: C:\to_your_project_directory> cd android
PS: C:\to_your_project_directory\android> .\gradlew clean
PS: C:\to_your_project_directory\android> ./gradlew wrapper --gradle-version version_here(x.x.x) --distribution-type all
or
PS: C:\to_your_project_directory\android> ./gradlew wrapper --gradle-version version_here(x.x.x)
or
PS: C:\to_your_project_directory\android> ./gradlew wrapper --gradle-version latest
Under the settings.gradle
:
id ".jetbrains.kotlin.android" version "2.0.21" apply false //if necessary, downgrade it. Here is the reference
Under the android\build.gradle
:
buildscript {
ext.kotlin_version = '2.0.21' //if necessary, downgrade it.
repositories {
google()
mavenCentral()
}
dependencies {
classpath ".jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Also, consider this compatibility matrix
Update:
Please use these approaches if necessary:
In your Android Studio, Go to File > Invalidate Caches
Then you can do some troubleshooting practices:
PS: C:\to_your_project_directory> flutter clean
PS: C:\to_your_project_directory> flutter pub get
PS: C:\to_your_project_directory> flutter pub cache repair
PS: C:\to_your_project_directory> cd android
PS: C:\to_your_project_directory\android> .\gradlew clean
Additionals:
PS: C:\to_your_project_directory\android> ./gradlew build --stacktrace --info
To see what plugins or packages introduces the issues
NOTE:
The goal is to make sure that after you configure build.gradle, gradle-wrapper.properties, etc. You also clean the caches, then rebuild them.
I hope it helps!
本文标签:
版权声明:本文标题:Why does Flutter fail to compile as soon as any package is added to the pubspec.yaml in Android Studio? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745625525a2159835.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
flutter pub get
after adding the dependency? – Tim Hansen Commented Nov 18, 2024 at 10:53