LoginSignup
0
0

More than 1 year has passed since last update.

【Flutter】Firebaseと連携時にエラー

Posted at

初めに

Flutterで個人的に開発途中、Firebaseと連携しアプリをビルド
したところエラーが発生。。

ちょっとみたこと無いエラーだったので
備忘録として記録。

エラー内容

どうやらappフォルダ直下のbuild.gradleに何かありそう。。

FAILURE: Build failed with an exception.

* Where:
Build file '~/flutter_sample/android/app/build.gradle' line: 29

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method id() for arguments [com.google.gms.google-services] on project ':app' of type org.gradle.api.Project.

場所を教えてくれている。。
素直にbuild.gradleを確認。。

app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
id 'com.google.gms.google-services' // ←これについて何か言ってる

うーん、直感ではこの「id」という書き方があかん感じ。。
仕方ない、FlutterとFirebaseの連携について
ググって情報収集しよう。。

そんな中build.gradleについてこんな記載が。。

app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services' // ← 「id」じゃない!?

どうやらidではなく「apply plugin」という記載が正しいっぽいので
同じ内容に修正。。

再度ビルドしたら別のエラーが発生。。

.gradle/caches/transforms-2/files-2.1/95d7102c3bcd9bd5e3f48b4a45f773e4/jetified-firebase-analytics-ktx-20.0.2-api.jar!/META-INF/java.com.google.android.libraries.firebase.firebase_analytics_ktx_granule.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details

うわなにこれ。。
と諦めかけていたその時、「The binary version of its metadata is 1.5.1」
という記載が目に入る。。

どうやらKotlinのなにかしらのモジュールに関するバージョンが
誤っているっぽい。。

そこでググった情報を基に、android直下の方のbuild.gradleを
修正。

修正前

build.gradle
ext.kotlin_version = '1.3.50'

修正後

build.gradle
ext.kotlin_version = '1.6.0'

「ext.kotlin_version」 についてはまだ調べられておらず。。
何かご存知な方いらっしゃったら教えてください!

上記対応後、無事に動きました!
FirebaseやAndroidプロジェクトについてまだまだ
勉強不足ですね。。w

参考文献

0
0
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
0
0