Closed2

Flutter v3.27 Android Copyタスクにて依存関連のエラー

greendropgreendrop

Flutter v3.27.1 への更新で、 Gradle も8系に更新したところ、 Gradle のCopyタスクで依存関連でエラー

Copyタスクを利用しているのは、とてもお世話になっているこちら
https://zenn.dev/altiveinc/articles/separating-environments-in-flutter

エラー内容

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':app:selectGoogleServicesJson' (type 'Copy').
  - Gradle detected a problem with the following location: '/Users/katsuyuki/ghq/github.com/greendrop/flutter_news_sample/android/app'.

    Reason: Task ':app:compileFlutterBuildDebug' uses this output of task ':app:selectGoogleServicesJson' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':app:selectGoogleServicesJson' as an input of ':app:compileFlutterBuildDebug'.
      2. Declare an explicit dependency on ':app:selectGoogleServicesJson' from ':app:compileFlutterBuildDebug' using Task#dependsOn.
      3. Declare an explicit dependency on ':app:selectGoogleServicesJson' from ':app:compileFlutterBuildDebug' using Task#mustRunAfter.

    For more information, please refer to https://docs.gradle.org/8.3/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/Users/katsuyuki/ghq/github.com/greendrop/flutter_news_sample/android/app'.

    Reason: Task ':app:mergeDebugAssets' uses this output of task ':app:selectGoogleServicesJson' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':app:selectGoogleServicesJson' as an input of ':app:mergeDebugAssets'.
      2. Declare an explicit dependency on ':app:selectGoogleServicesJson' from ':app:mergeDebugAssets' using Task#dependsOn.
      3. Declare an explicit dependency on ':app:selectGoogleServicesJson' from ':app:mergeDebugAssets' using Task#mustRunAfter.

    For more information, please refer to https://docs.gradle.org/8.3/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/Users/katsuyuki/ghq/github.com/greendrop/flutter_news_sample/android/app'.

    Reason: Task ':app:mergeDebugShaders' uses this output of task ':app:selectGoogleServicesJson' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.

    Possible solutions:
      1. Declare task ':app:selectGoogleServicesJson' as an input of ':app:mergeDebugShaders'.
      2. Declare an explicit dependency on ':app:selectGoogleServicesJson' from ':app:mergeDebugShaders' using Task#dependsOn.
      3. Declare an explicit dependency on ':app:selectGoogleServicesJson' from ':app:mergeDebugShaders' using Task#mustRunAfter.

    For more information, please refer to https://docs.gradle.org/8.3/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

* 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 3m 52s
Error: Gradle task assembleDebug failed with exit code 1

Exited (1).
greendropgreendrop

Copy タスクが怪しいのかと思い、以下のように Copy タスクではないファイルコピー方法に変更でエラーは解消
(原因まではたどれてない)

-task selectGoogleServicesJson(type: Copy) {
-    from "src/${dartDefines.flavor}/google-services.json"
-    into './'
+task selectGoogleServicesJson {
+    doFirst {
+        copy {
+            from "src/${dartDefines.flavor}/google-services.json"
+            into './'
+        }
+    }
}
このスクラップは2024/12/28にクローズされました