LoginSignup
0
0

More than 3 years have passed since last update.

Firebase Crashlytics SDK 導入時にあった Gradle エラー

Last updated at Posted at 2020-10-15

firebase crashlytics SDK の導入時に以下のようなエラーがありました。

> Task :app:compileDebugKotlin FAILED
e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
    class com.google.android.gms.location.LocationResult, unresolved supertypes: com.google.android.gms.internal.zzbej


e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:

com.google.android.gms.location.LocationResult クラスの継承元の com.google.android.gms.internal.zzbej クラス が見つからないようです。

gradle ファイル

build.gradle ファイル

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

    // 移行中のため古い環境です
    //ext.kotlin_version = "1.4.0"
    ext.kotlin_version = "1.3.10"
    repositories {
        google()
        jcenter()
    }
    dependencies {

        // 移行中のため古い環境です
        //classpath "com.android.tools.build:gradle:4.0.1"
        classpath "com.android.tools.build:gradle:3.5.0"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle ファイル

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.example.gradleerrorsample"
        minSdkVersion 28
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            firebaseCrashlytics {
                mappingFileUploadEnabled false
            }
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation 'com.google.android.gms:play-services-location:11.6.2'

    implementation 'com.google.firebase:firebase-crashlytics:17.2.2'
}

調査

(1)

android studio から LocationResult クラスを参照してみました。

image.png

確かに zzbej クラスは見つかりません。

(2)

ビルドが通る状態まで戻しました (implementation 'com.google.firebase:firebase-crashlytics:17.2.2' をコメントアウト)。

image.png

zzbej クラスは、com.google.android.gms:play-services-basement:11.6.2 で定義されているようです。

(3)

(2) のコメントアウトを解除後、gradle app:dependencies を実行し、ライブラリの依存関係を出力しました。

image.png

262 - 271行は、play-services-location の依存関係です。
play-services-basement (264行など) や playservices-tasks (268行など) が 11.6.2 から 17.0.0 に変更されています。

272行からは、com.google.firebase:firebase-crashlytics の依存関係です。
以下の依存関係があるようです。

  • 288行より play-services-tasks の 17.0.0
  • 290行より play-services-basement の 17.0.0

play-services-location の同名のライブラリは、推移的な依存関係の解決により、新しいバージョンが使用されます。

対応

play-services-location を 17.0.0 に変更することで、ビルド自体はできるようになります。

image.png

参考

気をつけたいGradleの推移的依存関係とその解決

その他

(ライブラリの更新はまめにしましょう)

追記1

Release Notes : June 17, 2009 では、破壊的な変更を含んでいる。このリリース以降と以前のライブラリは、共存できないのでは ?

Firebase Crashlytics 17.0.0 のリリースは Release Notes : April 23,2020 なので、その他の google play services なライブラリも、移行が必要だったのでは。

(11.6.2 は古すぎだが)

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