【问题标题】:build error when adding crashlytics dependency in android在android中添加crashlytics依赖时构建错误
【发布时间】:2020-12-13 17:11:27
【问题描述】:

我想在我的项目中添加 Crashlytics

我在下面添加依赖

implementation 'com.google.firebase:firebase-crashlytics:17.3.0'

我的项目依赖

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.google.android.gms:play-services-vision:11.8.0'
implementation 'com.google.android.gms:play-services-location:11.8.0'
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
implementation 'me.anwarshahriar:calligrapher:1.0'
implementation 'com.baoyz.swipemenulistview:library:1.3.0'
implementation 'joda-time:joda-time:2.9.9'
implementation 'me.dm7.barcodescanner:zbar:1.9.8'
testImplementation 'junit:junit:4.12'
implementation 'com.google.apis:google-api-services-storage:v1-rev135-1.23.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-iid:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.wdullaer:materialdatetimepicker:3.6.3'
implementation 'com.android.support:support-v4:28.0.0-rc02'
implementation 'com.android.support:support-v13:28.0.0-rc02'
implementation 'com.android.support:cardview-v7:28.0.0-rc02'
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc02'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.code.gson:gson:2.8.5'
implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: 
'4.3.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.pusher:chatkit-android:1.0.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.itextpdf:itextg:5.5.10'
implementation 
'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
implementation 'com.github.f0ris.sweetalert:library:1.5.1'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.google.firebase:firebase-crashlytics:17.3.0'

我得到以下错误

class com.google.android.gms.maps.model.LatLng, unresolved 
supertypes:com.google.android.gms.internal.zzbfm
e: Supertypes of the following classes cannot be resolved.
Please make sure you have the required dependencies in the classpath:

在 BoM 下对所有 firebase 依赖项进行分组后的依赖项

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.google.code.gson:gson:2.8.0'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.google.android.gms:play-services-vision:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    implementation 'com.google.android.gms:play-services-analytics:11.8.0'
    implementation 'me.anwarshahriar:calligrapher:1.0'
    implementation 'com.baoyz.swipemenulistview:library:1.3.0'
    implementation 'joda-time:joda-time:2.9.9'
    implementation 'me.dm7.barcodescanner:zbar:1.9.8'
    testImplementation 'junit:junit:4.12'
    implementation 'com.google.apis:google-api-services-storage:v1-rev135-1.23.0'

    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.android.volley:volley:1.1.1'
    implementation 'com.wdullaer:materialdatetimepicker:3.6.3'
    implementation 'com.android.support:support-v4:28.0.0-rc02'
    implementation 'com.android.support:support-v13:28.0.0-rc02'
    implementation 'com.android.support:cardview-v7:28.0.0-rc02'
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
    implementation 'com.android.support:design:28.0.0-rc02'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.1'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.pusher:chatkit-android:1.0.0'

    implementation 'com.github.bumptech.glide:glide:3.7.0'
    // implementation files('libs/itextpdf-5.3.3.jar')
    implementation 'com.itextpdf:itextg:5.5.10'
    implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'

    implementation 'com.github.f0ris.sweetalert:library:1.5.1'


    implementation 'com.journeyapps:zxing-android-embedded:3.4.0'

    //FireBase
    implementation platform('com.google.firebase:firebase-bom:26.1.1')
    implementation 'com.google.firebase:firebase-database'
    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-messaging'
    implementation 'com.google.firebase:firebase-iid'
    implementation 'com.google.firebase:firebase-core'
    implementation 'com.google.firebase:firebase-crash'
    implementation 'com.google.firebase:firebase-firestore'

}

【问题讨论】:

  • 添加 crashlytics 后,请编辑问题以同时显示 build.gradle 中的所有依赖项。
  • 将问题编辑成什么?

标签: java android firebase crashlytics


【解决方案1】:

使用 Firebase 依赖项时,版本必须全部来自同一个“发布”时间点。你所没有的显示了很多年前的 很多 旧的 Firebase 依赖项。当您添加 Crashlytics 后,它们就完全不同步了。

您需要升级所有 Firebase 依赖项以匹配您在 documentation 中看到的内容。更好的是,由于您有这么多 Firebase 依赖项,请使用 Firebase BoM 为所有这些依赖项选择一个发布版本,而无需指定单独的依赖项版本。

【讨论】:

  • 我曾尝试升级 gms-play-services,然后我收到此错误消息,这是不言自明的,但我如何知道 gms 和 firebase 之间匹配的最新版本?所有 gms/firebase 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 17.0.0、11.8.0。示例包括 com.google.android.gms:play-services-base:17.0.0 和 com.google.android.gms:play-services-analytics:11.8.0
  • 我链接到的文档包含您需要的所有信息。版本号不再必须相同。该要求在多年前就被取消了。每个依赖项的版本必须来自同一个版本,对应于一个 BoM 版本。这就是为什么现在最好使用 BoM - 它会自动保持每个依赖版本彼此同步。
  • 感谢参考!我已将所有 firebase 依赖项分组在 BoM 26.1.1 下,但仍然存在问题中发布的相同错误。
  • 我看不到你做了什么,所以我不知道你是否做对了。听起来好像不正确。
  • 您还需要更新播放服务依赖项。
猜你喜欢
  • 2016-05-30
  • 2021-10-24
  • 2016-09-11
  • 2017-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多