2
2

More than 3 years have passed since last update.

flutter build apk --release だけ Could not resolve all files for configuration ':releaseRuntimeClasspath'.エラー

Last updated at Posted at 2020-11-27

flutter build apk --releaseのときだけ、以下のエラーが出てapkが作れない問題でハマりました。

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':generateReleaseRFile'.
> Could not resolve all files for configuration ':releaseRuntimeClasspath'.
   > Could not find com.google.firebase:firebase-bom:25.12.0.
     Searched in the following locations:
       - https://storage.googleapis.com/download.flutter.io/com/google/firebase/firebase-bom/25.12.0/firebase-bom-25.12.0.pom
       - https://storage.googleapis.com/download.flutter.io/com/google/firebase/firebase-bom/25.12.0/firebase-bom-25.12.0.jar
     Required by:
         project :
   > Could not find com.google.firebase:firebase-core:.
     Required by:
         project :
   > Could not find androidx.annotation:annotation:1.1.0.
     Searched in the following locations:
       - https://storage.googleapis.com/download.flutter.io/androidx/annotation/annotation/1.1.0/annotation-1.1.0.pom
       - https://storage.googleapis.com/download.flutter.io/androidx/annotation/annotation/1.1.0/annotation-1.1.0.jar
     Required by:
         project :

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

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':javaPreCompileRelease'.
> Could not resolve all files for configuration ':releaseCompileClasspath'.
   > Could not find com.google.firebase:firebase-bom:25.12.0.
     Required by:
         project :
   > Could not find com.google.firebase:firebase-core:.
     Required by:
         project :
   > Could not find androidx.annotation:annotation:1.1.0.
     Required by:
         project :

* 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 2s


The plugin firebase_core could not be built due to the issue above.

解決方法

Stackoverflowを参考に、flutter build apk --profile を一度実行すると、 --release でもビルドできるようになりました。

謎い

追記:本当の解決方法

gradleを4.1.0から3.5.0にしたら解決しました。
使っていたFlutter 1.22.2 で新規プロジェクトを作成したら3.5.0だったので、どうやら安易に変更してはいけないようです。

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2